Copy link to clipboard
Copied
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);
}
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Above is the content of my animation storybook, I have both the Button and ActionScript layer in every of the scenes.
Copy link to clipboard
Copied
no, you don't. more than 1/2 the frames shown do NOT contain the objects in THAT Button layer.
in addition, you have a second button layer shown which is definitely going to cause the problem i just explained you needed to avoid.
again, delete all your Button layers.
create a new layer, and in frame 1 add your buttons. extend that timeline to your last frame. if you don't have another scene (the way flash defines scenes), you should be able to test and see no problem.
Copy link to clipboard
Copied
Then how about the actionscript? Because I need to make sure the next and previous button is jumping towards the correct scene (which are the frames), so how am I going to write the script because my scene is not a movieclip it contains some animations and mouseEvents.
Copy link to clipboard
Copied
label those frames and use frame labels.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
Oh yes~! The problem solved like magic. Thank you so much kglad....
Copy link to clipboard
Copied
you're welcome.