Search code examples
flashactionscript-3cs3

Accessing parent properties/methods in Actionscript 3.0


I'm trying to control the main timeline of my flash application from a MovieClip that is a child of the main stage. Apparently, in ActionScript 2, you could do that using _root, but using root (since _root no longer exists) now gives an error:

root.play();

"1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer."

Using the Stage class also doesn't work:

stage.play();

"1061: Call to a possibly undefined method play through a reference with static type flash.display:Stage."

Is there any way to do this?


Solution

  • You need to cast it to a MovieClip

    (root as MovieClip).play()