A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Multiple keypress interactions slowing down Flash Player

  1. #1
    Junior Member
    Join Date
    Mar 2004
    Location
    near Tucson, Arizona (USA)
    Posts
    23

    Multiple keypress interactions slowing down Flash Player

    I'm using CS4 Professional with ActionScript 2.0.

    I'm working with a movie that contains 23 Tab keypress interactions, each of which uses this code (with each one navigating to a different frame number):

    Actionscript Code:
    var kl = new Object();
    kl.onKeyDown = function(){
        if(Key.isDown(Key.TAB)){
            gotoAndPlay(20);
        }
    };
    Key.addListener(kl);

    When I publish and play the movie, everything is fine until I hit the tenth interaction, at which point it plays more and more slowly. After about the thirteenth interaction a message displays that says,
    "A script in this movie is causing Adobe Flash Player to run slowly. If it continue to run, your computer may become unresponsive. Do you want to abort the script?"

    If I abort the script, the movie starts playing on its own without any user interaction, which is not what I want to happen.

    Any ideas about how to get around this problem?

    I've tried assigning different names to each variable (kl2, kl3, etc.) but that didn't help. I've also tried setting the value of the variable to null by adding kl="" to the end of the ActionScript. No luck there either.

    Any help would be appreciated.

    Thanks!

  2. #2
    Junior Member
    Join Date
    Mar 2004
    Location
    near Tucson, Arizona (USA)
    Posts
    23

    An answer

    OK, I'll answer myself. We borrowed one of the programmers and found a solution.

    On the very first frame of the movie we defined a global variable:

    Actionscript Code:
    _global.kl = new Object();

    On the first frame that contains a keypress interaction, we used this code:

    Actionscript Code:
    kl.onKeyDown = function(){
        if(Key.isDown(Key.TAB)){
            gotoAndPlay(20);
        }
    };
    Key.addListener(kl);

    On each subsequent frame that contains an interaction, we used this code:

    Actionscript Code:
    kl.onKeyDown = function(){
        if(Key.isDown(Key.TAB)){
            gotoAndPlay(30);
        }
    };

    Not defining the variable and including the listener on each frame with an interaction solved the slowdown problem and the movie plays just fine now.

  3. #3
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    nevermind, seems like you found a solution
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center