Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS3 Button inside a movieclip

New Here ,
Jun 05, 2016 Jun 05, 2016

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.

TOPICS
ActionScript
742
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 05, 2016 Jun 05, 2016

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.

Translate
Community Expert ,
Jun 05, 2016 Jun 05, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2016 Jun 06, 2016
LATEST

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines