0
votes

I'm new in Flash and AS3. I have problem whit my project. I want to keep my buttons working in all of my frames and keep them working no matter how many times they are click or rollover-d

My code:

stop();


button1.addEventListener(MouseEvent.MOUSE_OVER, goto);
button2.addEventListener(MouseEvent.MOUSE_OVER, goto1);
button3.addEventListener(MouseEvent.MOUSE_OVER, goto2);

function goto(e:MouseEvent):void {
gotoAndStop(2);
}

function goto1(e:MouseEvent):void {
gotoAndStop(3);
}

function goto2(e:MouseEvent):void {
gotoAndStop(4);
}

It is working ok for the first time but when I go to button1 it take mi to frame 2.. and button2 take mi to frame 3 but on frame 3 the button1 is not working anymore.

Its look like every button is working only one time.

I have the same buttons on all of my frames. It is going to be 82 buttons and 82 frames so its going to be a problem.

If someone is wondering I'm making interactive infographic.

I hope someone can help me.

2

2 Answers

0
votes

For this to work you should have all the buttons on a layer with no keyframes on it. If you have to have keyframes for whatever reason then you need to add the code for the buttons again on that/those additional keyframes.

0
votes

I think you can accomplish this with 3 layers. A layer with a stop(); in every keyframe (If that is what you want). The next layer will have the button event code in frame 1, but make sure you add "frames" (not keyframes) to make sure that layer exists in all your frames. The last layer will contain the buttons in frame 1, again make sure you add "frames" (not keyframes) to make sure that buttons exists in all your frames. This is my attempt at a diagram of what I just described.

Layers    [1][2][3][4][5]
Stops AS  [•][•][•][•][•]
Button AS [•            ]
Buttons   [•            ]

Hope this makes some sort of sense. Let me know if you have more questions.