Skip to main content
Known Participant
September 13, 2011
Question

How to assign code to buttons?

  • September 13, 2011
  • 1 reply
  • 981 views

the current code I have on the timeline now (where the buttons reside) is:

stop();

function playLifeboy(event:MouseEvent):void

{

gotoAndStop(3);

}

function playKrave(event:MouseEvent):void

{

gotoAndStop(2);

}

lifeboy_btn.addEventListener(MouseEvent.CLICK, playLifeboy);

krave_btn.addEventListener(MouseEvent.CLICK, playKrave);

These work fine the first time but when I return to them they don't work. (I was told I have to assign the code to the buttons, But how?)

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
September 13, 2011

The code to assign to the buttons needs to be in the frame that you return to, otherwise, if you leave them behind and return to them in some other frame they have no code assigned to them.

maxshreckAuthor
Known Participant
September 13, 2011

The code is in the frame that I return to (Frame 1). It is the only Frame where the buttons reside. When I return to them the buttons still work visually but the action doesn't work.

Participant
September 13, 2011

only an idea...if your action is an animation inside another movieclip you have to set the animation also to frame 1 and stop otherwise it would run all the time from the first click