0

So I have made 4 scenes. In the first scene there are 2 buttons, they both go the same next scene. In this next scene there's another button, but based on which button you clicked in the first scene, you go to the next.

Lets make it more clear:

Scene 1: Button1 and Button2

Scene 2: Button

Scene 3: Outcome based on Button1

Scene 4: Outcome based on Button2

This is what I've got:

scene1:

button1.addEventListener(MouseEvent.CLICK, nextSceneB1); 
button2.addEventListener(MouseEvent.CLICK, nextSceneB2); 

function nextSceneB1(event)
{
    MovieClip(root).gotoAndPlay(1,"scene2"); /
}

function nextSceneB2(event)
{
    MovieClip(root).gotoAndPlay(1,"scene2"); /
}

Scene 2: dont know what to add here

Scene 3: Outcome based on Button1

Scene 4: Outcome based on Button2

What should I do?

Gíp
  • 3
  • 7
  • Make Scene 2.1 and Scene 2.2 that look exactly the same, so the ways will be Scene 1 > Button 1 > Scene 2.1 > Button > Scene 3 and Scene 1 > Button 2 > Scene 2.2 > Button > Scene 4 respectively. – Organis Mar 28 '18 at 21:57
  • @Organis alright that will work! But it sounds like just a way to avoid extra coding, and to adding unnecessary scenes. Is this the best way to let it work? – Gíp Mar 28 '18 at 22:05
  • I just really don't like mixing scripts and timelines, it's the source of many headaches. Well, added an answer, should work, I think. – Organis Mar 28 '18 at 22:13
  • @Organis That's a good point. This will work for me, thanks! – Gíp Mar 28 '18 at 22:18

1 Answers1

0

Scene 1:

function nextSceneB1(e:Event):void
{
    // Create a field that keeps where to go next.
    MovieClip(root)['proceed'] = "scene3";
    MovieClip(root).gotoAndPlay(1, "scene2");
}

function nextSceneB2(e:Event):void
{
    // Create a field that keeps where to go next.
    MovieClip(root)['proceed'] = "scene4";
    MovieClip(root).gotoAndPlay(1, "scene2");
}

Scene 2:

function nextScene2B(e:Event):void
{
    // Use the kept field as an argument.
    MovieClip(root).gotoAndPlay(1, MovieClip(root)['proceed']);
}
Organis
  • 7,243
  • 2
  • 12
  • 14