Skip to main content
Known Participant
August 13, 2013
Answered

Button only works once! I NEED HELP~

  • August 13, 2013
  • 1 reply
  • 1883 views

Hi, I'm working on my project and it is basically a animated storybook. I have like 20+ scenes and in each of the scene there is a next and previous button to jump from scene to scene, but now I am facing a problem on my next and previous button which is when I perform test on FLV the button only works once. For example: I'm now in Scene 1 and I clicked on the next button to jump to the scene two, and when I clicked on the previous button to go back to Scene 1 the button is not working anymore. Can anyone please provide me a solution about my problem? I really appreciate that! >.<

This is my ActionScript Code for my button in every scenes:-

import flash.events.MouseEvent;

stop();

next_btn1.addEventListener(MouseEvent.CLICK, nextpage2);

function nextpage2(event:MouseEvent):void

{

          gotoAndStop(26);

}

PrvButton1.addEventListener(MouseEvent.CLICK, prvpage_main);

function prvpage_main(event:MouseEvent):void

{

          gotoAndStop(1);

}

This topic has been closed for replies.
Correct answer kglad

your button must continue to exist on all frames.

to remedy, create a new layer that contains your next and previous buttons.  add the buttons to frame 1 and assign instance names.  do NOT add any other keyframes, yet.

test.

if everything works, you can add keyframes where needed, but do NOT remove either button from any keyframe.

1 reply

kglad
kgladCorrect answer
Community Expert
August 13, 2013

your button must continue to exist on all frames.

to remedy, create a new layer that contains your next and previous buttons.  add the buttons to frame 1 and assign instance names.  do NOT add any other keyframes, yet.

test.

if everything works, you can add keyframes where needed, but do NOT remove either button from any keyframe.

Yui_GAuthor
Known Participant
August 13, 2013

Above is the content of my animation storybook, I have both the Button and ActionScript layer in every of the scenes.

kglad
Community Expert
August 14, 2013

Thanks for the reply kglad. I've deleted all the button layers in every scenes and created a button layer from frame 1 until the last frame, but I still got this output here that I don't really understand what it means.


you're trying to reference something that doesn't exist when your code executes.

for example, if you have code in MainP that tries to reference a button in Scene1, that will trigger the error you see.

to pinpoint your error(s), click file>publish settings>swf and tick "permit debugging".  retest.  the problematic line number(s) will be in the error message(s).