Quantcast
Channel: 2D Latest Topics
Viewing all articles
Browse latest Browse all 623

Access root stage instance when button is clicked

$
0
0

I have an instance of a button called myBtn on stage, and an instance of a square movie clip called myContainer- all of which published from flash.
Within myContainer i have a movieclip instance named mySquare which is animated via classic tween from one point of the stage to another.
When the stage is loaded i use this.myBtn.on("click", startBtnOnClick) to add an event listener to the button, and the function startBtnOnClick(evt) is indeed successfully called.
What i'm trying to achieve is to tell myContainer to start playing when the button is clicked, and to do so i currently need to use:
evt.target.parent.parent.myContainer.gotoAndPlay(0) which works, but doesn't seem to be a best practice here.
What would be a more suitable approach?

Perhaps i should dispatch a new event when the button is clicked and listen for it in the container?


Viewing all articles
Browse latest Browse all 623

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>