Copy link to clipboard
Copied
As I've only started to learn AS3, I have a really simple question, but I can't figure it out.
I have a movieclip with instance name mcChange, and it has a button inside btnBack. When the button is clicked, I want it to go to the very beginning, to the first frame on the main stage.
I would really appreciate if you could help me with this one.
where's the code located?
if on mcChange's timeline when the button exists:
btnBack.addEventList...
if on the parent timeline of mcChange after mcChange and btnBack exist:
mcChange.btnBack.addEventList...
the code that should be in the listener function depends where the code is located and where the main stage is relative to the code location, though someone is bound to suggest MovieClip(root) to reference the main timeline, which is always poor coding but will often work.
Copy link to clipboard
Copied
where's the code located?
if on mcChange's timeline when the button exists:
btnBack.addEventList...
if on the parent timeline of mcChange after mcChange and btnBack exist:
mcChange.btnBack.addEventList...
the code that should be in the listener function depends where the code is located and where the main stage is relative to the code location, though someone is bound to suggest MovieClip(root) to reference the main timeline, which is always poor coding but will often work.
Copy link to clipboard
Copied
change instance property MOVIE CLIP to BUTTON then select last fram of the button and put this code in ACTION area
INSTANCE_NAME.addEventListener(MouseEvent.CLICK,PlayAgain);
function PlayAgain(E:MouseEvent):void
{
gotoAndPlay(SCENE_NUMBER);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now