Skip navigation
Gamera_Jr
Currently Being Moderated

Flash file will occasionally ignore Actionscript 2

Mar 30, 2012 7:03 AM

Tags: #help #flash #actionscript #2.0

I have some touchscreens I maintain at work, we use Flash with Actionscript 2 to display the content. The touchscreens display a series of images as a screensaver, then when you touch the screen it goes to the main menu. Occasionally when you touch the screen, the file will then start simply going through every frame in the file in order and ignoring all the actionscript. I can't tell if this is a hardware or scripting issue, since I can't reproduce it with any regularity, but it happens often enough to be annoying. It definitely seems to happen in the transition between screensaver loop and the main menu.

 

The screensaver button script is simply:

on (release)

{

    gotoAndPlay ("Bumper");

}

 

The menu menu and every section of content has script like this:

stop();

 

//number of second to wait before going to screensaver

//var secondsToWait = 40;

 

 

//converts milliseconds to seconds;

var duration = 1000 * _global.timeToWait;

var inv;

 

// the function to activate the screensaver (go to frame 1 or "slideshow")

// and clear the interval

function screensaver() {

clearInterval(inv);

gotoAndPlay("screensaver");

}

 

//sets the interval to run the screensaver function every 40 seconds(1000ms * 4 = 40 seconds)

function inactive(){

inv = setInterval(this,"screensaver", duration);

}

 

function reset(){

    clearInterval(inv);

}

 

//clears previous timer

reset();

 

 

//calls the inactive function.

inactive();

 

Any idea what might be doing this?

 
Replies
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 30, 2012 7:29 AM   in reply to Gamera_Jr

    a failure to clear all intervals.

     

    always clear intervals before setting them to ensure there are no run-away intervals.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 30, 2012 2:54 PM   in reply to Gamera_Jr

    if that frame (or those frames) play before an interval is cleared, the interval in inactive() is apt to never be cleared.  use:

     

    stop();

     

    //number of second to wait before going to screensaver

    //var secondsToWait = 40;

     

     

    //converts milliseconds to seconds;

    var duration = 1000 * _global.timeToWait;

    var inv;

     

    // the function to activate the screensaver (go to frame 1 or "slideshow")

    // and clear the interval

    function screensaver() {

    clearInterval(inv);

    gotoAndPlay("screensaver");

    }

     

    //sets the interval to run the screensaver function every 40 seconds(1000ms * 4 = 40 seconds)

    function inactive(){

    clearInterval(inv);  // always clear the interval before setting.  ie, every setInterval() should be preceded by a clearInterval()

    inv = setInterval(this,"screensaver", duration);

    }

     

    function reset(){

        clearInterval(inv);

    }

     

    //clears previous timer

    reset();

     

     

    //calls the inactive function.

    inactive();

     
    |
    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