A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: _currentframe trouble

  1. #1
    I have ear-mites! Help! MONSTERBOY's Avatar
    Join Date
    Mar 2002
    Location
    LA
    Posts
    345

    _currentframe trouble

    This is a retarted problem but I can't figure it out.
    I have a movie with stop() on the first frame.
    Then I have a key listener with this code:

    Code:
    stop();
    //
    var f = {};
    f.onKeyUp = function() {
    	//space bar
    	if (Key.getCode() == 32) {
    		nextFrame();	}
    	// right key          
    	if (Key.getCode() == 39) {
    		nextFrame();	}
    	// left key          
    	if (Key.getCode() == 37) {
    		prevFrame();	}
    	trace(_currentframe);
    };
    Key.addListener(f);
    The problem is when I go forward, then backwards, then forwards again, the movie jumps forward too many frames. It's so weird. I don't understand!! it's so stupid.
    Please help!

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Location
    Malibu
    Posts
    251
    The problem is everytime you return to the first frame of your movie you are creating another Key.listener - hence, the onKeyUp function gets called twice for every KeyUP action.

    Try this

    Code:
    stop();
    //
    if (f == undefined) {
    	var f = {};
    	f.onKeyUp = function() {
    		//space bar
    		if (Key.getCode() == 32) {
    			nextFrame();	}
    		// right key          
    		if (Key.getCode() == 39) {
    			nextFrame();	}
    		// left key          
    		if (Key.getCode() == 37) {
    			prevFrame();	}
    		trace(_currentframe);
    	};
    	Key.addListener(f);
    }
    www.electricbluemonkey.com

  3. #3
    I have ear-mites! Help! MONSTERBOY's Avatar
    Join Date
    Mar 2002
    Location
    LA
    Posts
    345
    Thanks alot man, that was exactly the problem. I'm new to listeners. Thanks.

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