Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access variable of parent movie clip in Action script 3.0

How to access variable of parent movie clip in child movie clip in Action script 3.0

Thanks.

like image 622
Vijay Bagul Avatar asked Jan 27 '26 06:01

Vijay Bagul


1 Answers

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.

like image 145
Marty Avatar answered Jan 28 '26 21:01

Marty