Buttons : Previous, Next, Return
The purpose is to show how to manage buttons Previous, Next, Return in a scene to get from a sequence to another.
We'll use scripts. I suppose you know how to create objects, thus I will not insist on.
Here is a scenario for a scene named Scene_2 :
I'll suppose buttons have been created and pictures set up with their effects.
You 'll notice some stops limit display sequences.
We 'll use a variable named clic in that scene.
For the others, you MUST use another name : clic1, clic2, ...
Here is the script placé for Scene_2 in Outline.
onLoad() { clic = 0; }
onFrame (21) { stop(); }
onFrame (42) { stop(); }
onFrame (63) { stop(); }
onFrame (84) { stop(); }
onFrame (105) { stop(); }
onFrame (126) { stop(); }
onFrame (147) { stop(); }
Here is the script for the button Next in Outline.
on (press)
{
clic++;
switch (clic)
{
case 1 : gotoAndPlay("Scene_2",22); break;
case 2 : gotoAndPlay("Scene_2",43); break;
case 3 : gotoAndPlay("Scene_2",64); break;
case 4 : gotoAndPlay("Scene_2",85); break;
case 5 : gotoAndPlay("Scene_2",106); break;
case 6 : gotoAndPlay("Scene_2",127); break;
case 7 : gotoAndPlay("Scene_2",148); break;
case 8 :
clic = 0; // init
gotoAndPlay("Scene_2",1); // back to startup
break;
}
}
Here is the script for the button Previous in Outline.
Place this button only in the 2nd sequence ( frame 22 ).
on (press)
{
clic--;
switch (clic)
{
case 0 : gotoAndPlay("Scene_2",1); break;
case 1 : gotoAndPlay("Scene_2",22); break;
case 2 : gotoAndPlay("Scene_2",43); break;
case 3 : gotoAndPlay("Scene_2",64); break;
case 4 : gotoAndPlay("Scene_2",85); break;
case 5 : gotoAndPlay("Scene_2",106); break;
case 6 : gotoAndPlay("Scene_2",127); break;
}
}
For button Menu, it's quite simple.
We get back to the original Scene_1 which is used for dispatching.
on (release) { gotoSceneAndPlay("Scene_1",1); }
Et voilà, quite easy, no ? You just have to fit with your own stop positions.
Remark :
It'll be more flexible to use labels instead of references to a frame number.
For that, see SwishMax2.