Skip navigation
Currently Being Moderated

Flag or Variable Required for Navigation

Jun 20, 2007 5:57 AM

I need some help with (hopefully) a small addition to my actionscript.

I have a touchscreen in our reception, the Flash presentation on here currently has a set-up screen (1st Scene, named "Input") with a text input box, the results of which get displayed on the next Scene which is called "Welcome". When a visitor touches the screen the presentation jumps to another Scene called "Main". On the timeline of "Main" there's a counter set up to detect whether the screen has been touched in the last 5 mins, if not the presentation jumps back to "Welcome", waiting for the next touch.

I'd like to change the "Input" Scene and have two options for the person setting up the presentation (someone has to do this every morning). I'd like two welcome screens, one with a static standard greeting "Welcome to Gillingham" for example. The other welcome screen would be the same as described above with the input text box.

The trouble is once the presentation jumps into the "Main" Scene, there's no way to indicate from WHICH welcome screen it started from - the static text or the input text. So what I think I need is a simple variable or "flag" somewhere in the timer actionscript to indicate that if the flag is on go to "Welcome_1" and if not go to "Welcome_2" after the 5mins of inactivity.

Here's my timer script set-up on Frame 1 of the "Welcome" Scene:

DisplayedCompany.text=_root.CompanyName;
var timeoutID = setInterval(timedOut, 180000);

function timedOut () {
clearInterval(timeoutID);
gotoAndStop("Welcome",1);
}

onMouseMove = function(){
clearInterval(timeoutID);
timeoutID = setInterval(timedOut, 180000);
}


And here's my timer script on Frame 1 of my "Main" Scene - looking for activity within 5 mins:

if(!timeoutID){
var timeoutID = setInterval(timedOut, 180000);
}

function timedOut () {
clearInterval(timeoutID);
_root.gotoAndStop("Welcome_1"); // be sure to label this frame on Welcome's frame 1.
}

onMouseMove = function(){
clearInterval(timeoutID);
timeoutID = setInterval(timedOut, 180000);
}

I'm not a programmer, all of the above script has been suggested by other forum users, so a very simple explanation on what I suspect is a very simple addition would be much appreciated.
 
Replies
  • Currently Being Moderated
    Jun 20, 2007 6:25 AM   in reply to Paradigm


    Set a variable to indicate the welcome screen such as welcomeId.
    var welcomeId:Number; // On first frame before all others

    welcomeId = 1; // On first frame for the main scene

    welcomeId = 2; // On first frame for the input scene.

    In the timeOut()
    if (welcomeId == 1)
    {
    _root.gotoAndStop("Welcome_Main"); // Supply correct scene names
    }
    else
    {
    _root.gotoAndStop("Welcome_Input");// Supply correct scene names
    }
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2007 6:27 AM   in reply to Paradigm
    If you have a syntax error, the code is not going to work.
    Without providing the error message, it is not going to be easy to dig it out, but using the rule of looking at code changes first is the error a missing close curly brace here

    else

    _root.gotoAndStop(Welcome, "Welcome_1");
    }

    Not sure what code goes before the } but {} are a block of code. There is a line that precedes {} such as if or else or function that defines when the block is played.



    A possible runtime logic error may occur if the welcomeId variable is not maintained. So I am not sure if you are returning to the "Input" scene. If you are then that variable value gets destroyed.

    You need to declare
    var welcomeId:Number;
    once and I am not sure where that would be in your code but it needs to be on a frame that is played only one time before the other frames are played that use welcomeId.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points