Access root stage instance when button is clicked

Recommended Posts

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?

Share this post

Link to post
Share on other sites

More info may be helpful. For example, is each clip displayed by a separate container on the page with a separate button for each container? Or, is there one button and one container and you have some mechanism for switching clips within the container?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.