How to access variable of parent movie clip in Action script 3.0
How to access variable of parent movi开发者_运维百科e clip in child movie clip in Action script 3.0
Thanks.
Same way you would access a variable of any object, using parent
as the target object. Because the parent
property is of type DisplayObjectContainer
, you will need to cast it to MovieClip
like so:
trace((parent as MovieClip).myvar);
The reason for the need to cast to MovieClip
is that it is dynamic
, meaning you won't get compile-time errors for attempting to access properties that the compiler doesn't know about.
精彩评论