Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Referring a Specific Scene to Scene/Access from multiple Scenes

New Here ,
Aug 03, 2018 Aug 03, 2018

Below I have attached a picture that describes what I am talking about.  I have a predicament with my project as I have quite a few scenes now and was hoping there was a simple fix/cleaner way to accomplish the task.

TOPICS
ActionScript
407
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 03, 2018 Aug 03, 2018

You could have a function in each scene that stored the frame and scene that you had come from. In Scene A for example you might have a button that when you click on it you would go to Scene 2. The script would be like this (the button is named 'testbtn' for my example):

import flash.events.MouseEvent;

testbtn.addEventListener(MouseEvent.CLICK, gootherscene);

stop();

function gootherscene(e: MouseEvent) {

  testbtn.removeEventListener(MouseEvent.CLICK, gootherscene);

  var f: int = currentFrame;

  var

...
Translate
LEGEND ,
Aug 03, 2018 Aug 03, 2018

You could have a function in each scene that stored the frame and scene that you had come from. In Scene A for example you might have a button that when you click on it you would go to Scene 2. The script would be like this (the button is named 'testbtn' for my example):

import flash.events.MouseEvent;

testbtn.addEventListener(MouseEvent.CLICK, gootherscene);

stop();

function gootherscene(e: MouseEvent) {

  testbtn.removeEventListener(MouseEvent.CLICK, gootherscene);

  var f: int = currentFrame;

  var s: String = "Scene A";

  gotoAndStop(1, "Scene 2");

  setreturn(f, s)

}

That function would take you over to Scene 2, and it would call a function 'setreturn', to make a note of where you came from.

In Scene 2 (and all other scenes) you would have this script:

import flash.events.MouseEvent;

var returnscene:String;

var returnframe:int;

returnbtn.addEventListener(MouseEvent.CLICK,doreturn);

function setreturn(framenumber:int,scenename:String){

  returnframe = framenumber;

  returnscene = scenename;

}

function doreturn(e:MouseEvent){

  returnbtn.removeEventListener(MouseEvent.CLICK,doreturn);

  gotoAndStop(returnframe,returnscene);

}

When the return button (named 'returnbtn' in my example) is clicked, it would go back to the frame and scene that you had come from.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 06, 2018 Aug 06, 2018

Thank you Colin for this answer, it seems to work perfectly!  Hopefully I will be able to better organize my animate file because of this seemingly easy function!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 06, 2018 Aug 06, 2018
LATEST

Glad it worked out ok!

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