A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: on key troubles...

  1. #1
    Junior Member
    Join Date
    Apr 2002
    Posts
    15

    Thumbs up

    I'm trying to have my movie clip pause/stop when you hit the space bar & on release it continues to play.

    I've tried this, but i'm sure its horriblely wrong;

    Code:
    Key.SPACE.onKeyDown = function(stop) {
        Key.SPACE.onKeyUp = function(play) {
        };
    };

  2. #2
    Senior Member vevmesteren's Avatar
    Join Date
    Sep 2001
    Location
    Montréal, Québec
    Posts
    566
    Try attaching this to your movieclip this:
    onClipEvent(enterFrame){
    if (key.isDown(Key.SPACE){
    _root.yourmovie.stop();
    }
    if (key.isUp(Key.SPACE){
    _root.yourmovie.play();
    }
    }

  3. #3
    Junior Member
    Join Date
    Apr 2002
    Posts
    15
    opps my bad it's from the 'root of scene 1' i haven't combined it as a movie clip

    maybe i should

    o_0

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    Code:
    _root.onKeyDown = function () {
    	if (Key.isDown(Key.SPACE) {
    		stop();
    		spaceDown = true;
    	}
    }
    _root.onKeyUp = function () {
    	if (spaceDown) {
    		play();
    		spaceDown = false;
    	}
    }
    vevmesteren's code wont work because there is no Key.isUP() meathod.

  5. #5
    Junior Member
    Join Date
    Apr 2002
    Posts
    15
    I tried yours and got this in the output:

    Code:
    Scene=Scene 1, Layer=action b, Frame=1: Line 2: ')' expected
         	if (Key.isDown(Key.SPACE) {
    test url: http://www.hellmedia.com/xtr/space.html

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    OK, so i forgot a )...

    That means this:

    if (Key.isDown(Key.SPACE)

    Should be:

    if (Key.isDown(Key.SPACE))

  7. #7
    Junior Member
    Join Date
    Apr 2002
    Posts
    15
    hmm, that validates the code.

    but it doesn't work.


    test url: ( http://www.hellmedia.com/xtr/space.html )
    test fla: ( http://www.hellmedia.com/xtr/space.fla )


  8. #8
    Senior Member vevmesteren's Avatar
    Join Date
    Sep 2001
    Location
    Montréal, Québec
    Posts
    566

    Smile sorry

    sorry about that

    Originally posted by etcettra
    Code:
    _root.onKeyDown = function () {
    	if (Key.isDown(Key.SPACE) {
    		stop();
    		spaceDown = true;
    	}
    }
    _root.onKeyUp = function () {
    	if (spaceDown) {
    		play();
    		spaceDown = false;
    	}
    }
    vevmesteren's code wont work because there is no Key.isUP() meathod.

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