A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Starting moving by pressing enter

  1. #1
    Junior Member
    Join Date
    Sep 2005
    Posts
    5

    Starting moving by pressing enter

    Just as the title says, I want to have a stop action on my first frame and have a code the will play the the movie once you press "Enter" on the key board.

    I'm using actionscript 2. Any help would be great

  2. #2
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    Try like so:

    PHP Code:
    stop();

    this.onEnterFrame = function () {
        if(
    Key.isDown(Key.ENTER))  {
            
    this.play();
        }
    }; 
    I'm using "this" to refer to the timeline, it doesn't have to be like that. I just like to have a reference to the thing I'm talking about. And it could refer to anything, like _parent, _root, my_mc, etc.

  3. #3
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Hey, try something like this,...
    PHP Code:
    stop();
    keyListener = new Object();
    keyListener.Key.ENTER = function() {
        
    play();
    }; 
    HTH.
    Wile E. Coyote - "Clear as mud?"

  4. #4
    Junior Member
    Join Date
    Sep 2005
    Posts
    5
    Quote Originally Posted by rickibarnes
    Try like so:

    PHP Code:
    stop();

    this.onEnterFrame = function () {
        if(
    Key.isDown(Key.ENTER))  {
            
    this.play();
        }
    }; 
    I'm using "this" to refer to the timeline, it doesn't have to be like that. I just like to have a reference to the thing I'm talking about. And it could refer to anything, like _parent, _root, my_mc, etc.
    This one worked, even though the last line made no sense to me
    Quote Originally Posted by Robb@exo
    Hey, try something like this,...
    PHP Code:
    stop();
    keyListener = new Object();
    keyListener.Key.ENTER = function() {
        
    play();
    }; 
    HTH.
    I couldn't get this working

    But thanks to the both of you, really helpful

  5. #5
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    Actually the way Robb@exo said to do it is a better way! I'm not very good at listening objects though (you could probably guess, since I didn't think of that!), but that code looks like it should work fine.

    I'd pursue that more, since as I said, that would be a much better way of doing it.

  6. #6
    Junior Member
    Join Date
    Feb 2008
    Posts
    28
    If you want to use AS3 it would be this:

    PHP Code:
    stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownListener);
    function 
    keyDownListener(e:KeyboardEvent):void {
                    if (
    e.keyCode==13) {
                    
    gotoAndPlay(2);
                    }
                    }
    stop(); 
    *This is AS not PHP

  7. #7
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    That's odd, because when tested, my code worked for me.
    Last edited by Robb@exo; 03-21-2008 at 10:38 PM.
    Wile E. Coyote - "Clear as mud?"

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