I need to stop the movie at the first frame using a function from a class, I know I can use stop(); or this.stop(); but how do I stop the main timeline from within a class function?
package {
public class myApplication {
public function myApplication(stageRoot:Stage) {
stop(); // this doesn't work
this.stop(); // this doesn't work either
}
}
}
You can access the main timeline from any display object (that is on the display list) by using the
root
keyword:If your class is not on the display list (as appears to be your case), then you'll need to pass in a reference to something that is. I see you are passing in a stage reference, so you could use that:
The main timeline (unless you've manually added something else to the stage at position 0) will be the first child of the
stage
.So you code would then look like this:
OR, if based off your comments you just pass root timeline in: