Copy link to clipboard
Copied
Hi.
I'm new to actionscript 3.
Main (scene 1)
stop();
import flash.events.*;
import flash.display.*;
1_btn.addEventListener(MouseEvent.CLICK, go1);
2_btn.addEventListener(MouseEvent.CLICK, go2);
3_btn.addEventListener(MouseEvent.CLICK, go3);
4_btn.addEventListener(MouseEvent.CLICK, go4);
5_btn.addEventListener(MouseEvent.CLICK, go5);
6_btn.addEventListener(MouseEvent.CLICK, go6);
7_btn.addEventListener(MouseEvent.CLICK, go7);
8_btn.addEventListener(MouseEvent.CLICK, go8);
9_btn.addEventListener(MouseEvent.CLICK, go9);
10_btn.addEventListener(MouseEvent.CLICK, go10);
function go1(evt:MouseEvent):void {
gotoAndStop(1, "1");
}
function go2(evt:MouseEvent):void {
gotoAndPlay(1, "2");
}
function go3(evt:MouseEvent):void {
gotoAndPlay(1, "3");
}
function go4(evt:MouseEvent):void {
gotoAndPlay(1, "4");
}
function go5(evt:MouseEvent):void {
gotoAndPlay(1, "5");
}
function go6(evt:MouseEvent):void {
gotoAndPlay(1, "6");
}
function go7(evt:MouseEvent):void {
gotoAndPlay(1, "7");
}
function go8(evt:MouseEvent):void {
gotoAndPlay(1, "8");
}
function go9(evt:MouseEvent):void {
gotoAndPlay(1, "9");
}
function go10(evt:MouseEvent):void {
gotoAndPlay(1, "10");
}
Now from any of the 10 scenes:
stop();
//Tried with and without the following 2 lines
import flash.events.*;
import flash.display.*;
main_btn.addEventListener(MouseEvent.CLICK, goM);
function goM(evt:MouseEvent):void {
gotoAndStop(1, "Main");
}
When I test error 1120 happens
Does anyone know what I do wrong? And how can I fix it? I want that you can go to every scene from main menu and from every scene back to main menu.
Copy link to clipboard
Copied
in animate it's problematic to name things using or starting with numbers. i don't know if that's triggering the error, but you should change those scene names.
click file>publish settings>swf and tick 'permit debugging'. the line number of the problematic object will be in the error message allowing you to pinpoint the error.
Copy link to clipboard
Copied
all your buttons should look like this.
Play_btn.addEventListener(MouseEvent.CLICK,gotoScene2);
function gotoScene2(evt:MouseEvent){
movClip.gotoAndPlay(1,"Scene 2");
}
Copy link to clipboard
Copied
Numbers aren't the problem, I just put them as example here. It is just when I want to spread this over different scenes and not just in one.
What I want to do is to have a main scene from which you can go to every other scene, and from every other scene back to the main scene. With buttons. I don't understand why there is an error.
Play_btn.addEventListener(MouseEvent.CLICK,gotoScene2);
function gotoScene2(evt:MouseEvent){
gotoAndPlay(1,"Scene 2");
}
If I put this in just one scene it works. Just when I put it in more than one scene. Also tried to do in one scene in different frames. Same problem. =/
(Of course I changed name of button and function for each button in code)
Copy link to clipboard
Copied
what line number is triggering the first error.
Copy link to clipboard
Copied
One issue seems to relate to using Advanced Layers. When you do that and you go to another scene, the main_btn causes an error, because it can't be found. Go into Modify/Document... and turn off Advanced Layers.
That will be enough to get you in and out of the first scene, but then when you place the same function on more than one scene you get a new error, for having a duplicate function. That can be solved by putting your main_btn into a movieclip, and give that movieclip a frame 1 script like this:
main_btn.addEventListener(MouseEvent.CLICK,gomain);
function gomain(e:MouseEvent){
MovieClip(this.parent).gotoAndStop(1,"Main");
}
Now you can place that new movieclip into all of the scenes, and it will work everywhere without there being a duplicate function.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now