I just can not get this. I have used button componant on scene one and I want to go to scene 2, frame 1 when pressed.
What is the AS for this ?
Does the stop command go into frame one of scene 1 and 2 ?
On the stage I click the button and gave it an instance, what AS do I use ? or does all the action code go into frame one and not the button itself?
If you can, don’t use scenes with ActionScript. They are good for animation, but they will cause some trouble with AS because they don’t work as expeected, and you don’t have control over them.
Assign an instance name to the button, my_btn for example.
Assign a frame label to the frame 1 of scene 2 (or any other frame you want to send the playhead to), for example myLabel.
Although you have a button component, this code that works for a button also works for it:
I don’t know if this is a good practice, but I’d say it isn’t, because the code used to control a button component can be the following, and code similar to this is used to control all the other components. So you should get familiar with it.
// import the class
import mx.controls.Button;
var my_btn:Button;
// create the listener
var my_btnListener:Object = new Object();
// use the click method
my_btnListener.click = function()
{
gotoAndStop("myLabel");
};
// make the listener listen to the click method
my_btn.addEventListener("click", my_btnListener);
You only use a stop() when the playhead is moving, and you want it to stop in that specific frame. The playhead has to come from the previous frame, and possibly the frame before, and so on.
Otherwise you just use gotoAndStop().
If the movie plays from frame 1 to 25 and you want to stop it at 25, you add a stop() to 25.
If the movie jumps from 1 to 25 directy, and you want it to stop there, you use gotoAndStop(25).