actionscript-3flashmovieclipsceneadobe-animate

Flash actionscript 3.0 How to go to an specific scene based on a button from an earlier scene?


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?


Solution

  • 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']);
    }