Skip to main content
Ferenc Puskás
Participant
December 21, 2018
Question

Buttons to other scenes

  • December 21, 2018
  • 3 replies
  • 1090 views

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.

This topic has been closed for replies.

3 replies

Ferenc Puskás
Participant
December 22, 2018

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)

kglad
Community Expert
Community Expert
December 22, 2018

what line number is triggering the first error.

Community Expert
December 21, 2018

all your buttons should look like this.

Play_btn.addEventListener(MouseEvent.CLICK,gotoScene2);
function gotoScene2(evt:MouseEvent){
  movClip
.gotoAndPlay(1,"Scene 2");
}

kglad
Community Expert
Community Expert
December 21, 2018

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.