Jump to content

Access root stage instance when button is clicked


Bkf
 Share

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?

Link to comment
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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...