Highlighted

Forcing Loop Finish

Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

So, I have a flash file set up with several looping scenes and buttons that allow the users to jump back and forth between scenes.

Say the user clicks a button to jump to a new scene while in the middle of another one - is there a way to make sure the current loop will always run to it's end before switching to the new one, rather than immediately jumping to it as soon as the button is clicked?

Yes, t1, t2 and t3 are button instances.

I'm not sure, what you precisely mean with "so they have a lot of different instances. (20-30 or so in total)". But if you have 12 scenes and - at least maximally 12 button instances, they don't need to be all present in all scenes. Just place those into scenes which link to scenes you want to enable a user to get to in any given situation. If certain scene-buttons are not present, they can't be clicked and the associated scenes can't be reached.

In the concept I suuggested above you only must make sure that each scene has a dedicated button instance/name and that they are all prescribed in the central clickHandler().

Klaus

TOPICS
Discussions

Views

183

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Forcing Loop Finish

Explorer ,
Mar 03, 2019

Copy link to clipboard

Copied

So, I have a flash file set up with several looping scenes and buttons that allow the users to jump back and forth between scenes.

Say the user clicks a button to jump to a new scene while in the middle of another one - is there a way to make sure the current loop will always run to it's end before switching to the new one, rather than immediately jumping to it as soon as the button is clicked?

Yes, t1, t2 and t3 are button instances.

I'm not sure, what you precisely mean with "so they have a lot of different instances. (20-30 or so in total)". But if you have 12 scenes and - at least maximally 12 button instances, they don't need to be all present in all scenes. Just place those into scenes which link to scenes you want to enable a user to get to in any given situation. If certain scene-buttons are not present, they can't be clicked and the associated scenes can't be reached.

In the concept I suuggested above you only must make sure that each scene has a dedicated button instance/name and that they are all prescribed in the central clickHandler().

Klaus

TOPICS
Discussions

Views

184

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 03, 2019 0
Adobe Community Professional ,
Mar 04, 2019

Copy link to clipboard

Copied

Could you make it so that clicking a button sets a variable instead of immediately jumping to another scene? At the end each scene you could test the value of this variable and either repeat the current scene or jump to another scene.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 04, 2019 0
Explorer ,
Mar 04, 2019

Copy link to clipboard

Copied

Hmm, how would that look in AS3 code though?

Should've mentioned I'm a complete newbie to all of this and hopeless when it comes to scripting

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 04, 2019 0
Explorer ,
Mar 05, 2019

Copy link to clipboard

Copied

Still looking for an answer here~

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 05, 2019 0
Advocate ,
Mar 07, 2019

Copy link to clipboard

Copied

Maybe for you, ShaadeSilentpaw, maybe for others, an alternative solution to letting scenes first finish before navigating to another one.

In Scene 1, frame 1 put this code:

import flash.events.MouseEvent;

import flash.display.Scene;

var anotherScene: String = "no";

this.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(e: MouseEvent):void {

    var etn = e.target.name;

    switch (etn) {

        case "t1":

            anotherScene = "Scene 1";

            break;

        case "t2":

            anotherScene = "Scene 2";

            break;

        case "t3":

            anotherScene = "Scene 3";

            break;

    }

}

function navigateScenes():void {

    var scene: Scene = currentScene;

    if (anotherScene != "no") {

        gotoAndPlay(1, anotherScene);

    } else {

        gotoAndPlay(1, scene.name);

    }

}

This of course assumes you have 3 scenes with those names. Any different situation needs to be adapted accordingly. "t1", "t2" and "t3" are buttons placed in all scenes.

Okay, in every other scene, frame 1, put this to reset the loop behaviour

anotherScene = "no";

and in the last frame of all scenes trigger navigateScenes() with this:

navigateScenes();

Example: Dropbox - scenes_and_loops.zip

Klaus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 07, 2019 1
Explorer ,
Mar 07, 2019

Copy link to clipboard

Copied

Do the t1/t2/t3 etc represent button instances?

See, my flash has no less than 12 scenes - and all the buttons aren't always supposed to be visible, so they have a lot of different instances. (20-30 or so in total)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 07, 2019 0
Adobe Community Professional ,
Mar 05, 2019

Copy link to clipboard

Copied

Hi.

One approach you can follow is to have a variable to store the next scene you want to navigate to and then in the last frame of each scene you call the gotoAndStop method passing the value of that variable.

Here is an example with 3 buttons and 3 scenes.

AS3 code:

[Scene 1]

Frame 1

import flash.events.MouseEvent;

var destination:String;

function setScene1(e:MouseEvent):void

{

    destination = "Scene 1";

    play();

}

function setScene2(e:MouseEvent):void

{

    destination = "Scene 2";

    play();

}

function setScene3(e:MouseEvent):void

{

    destination = "Scene 3";

    play();

}

stop();

scene1Button.addEventListener(MouseEvent.CLICK, setScene1);

scene2Button.addEventListener(MouseEvent.CLICK, setScene2);

scene3Button.addEventListener(MouseEvent.CLICK, setScene3);

Frame 120 (the last one)

gotoAndStop(1, destination);

[Scene 2]

Frame 1

import flash.events.MouseEvent;

scene1Button.addEventListener(MouseEvent.CLICK, setScene1);

scene2Button.addEventListener(MouseEvent.CLICK, setScene2);

scene3Button.addEventListener(MouseEvent.CLICK, setScene3);

Frame 120 (the last one)

gotoAndStop(1, destination);

[Scene 3]

Frame 1

import flash.events.MouseEvent;

scene1Button.addEventListener(MouseEvent.CLICK, setScene1);

scene2Button.addEventListener(MouseEvent.CLICK, setScene2);

scene3Button.addEventListener(MouseEvent.CLICK, setScene3);

Frame 120 (the last one)

gotoAndStop(1, destination);

FLA download:

animate_cc_as3_navigate_scenes.zip - Google Drive

I hope this helps.

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 05, 2019 1
Advocate ,
Mar 08, 2019

Copy link to clipboard

Copied

Yes, t1, t2 and t3 are button instances.

I'm not sure, what you precisely mean with "so they have a lot of different instances. (20-30 or so in total)". But if you have 12 scenes and - at least maximally 12 button instances, they don't need to be all present in all scenes. Just place those into scenes which link to scenes you want to enable a user to get to in any given situation. If certain scene-buttons are not present, they can't be clicked and the associated scenes can't be reached.

In the concept I suuggested above you only must make sure that each scene has a dedicated button instance/name and that they are all prescribed in the central clickHandler().

Klaus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 08, 2019 0