-
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
-
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.
-
Senior Member
Hey, try something like this,...
PHP Code:
stop(); keyListener = new Object(); keyListener.Key.ENTER = function() { play(); };
HTH.
Wile E. Coyote - "Clear as mud?"
-
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
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
-
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.
-
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
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|