Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-30-2002, 01:15 AM   #1
.chluaid
Registered User
 
Join Date: Jul 2002
Location: Sydney Australia
Posts: 5
Send a message via ICQ to .chluaid
Default controlling player in Flash game

I've started learning to build games in Flash and have a question regarding onClipEvent (enterFrame)

I have a test character whose animation is controlled by arrow-key presses and currently his mc code goes like this..


onClipEvent (enterFrame){
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
gotoAndPlay ("leap");
}
}



It all works fine, as you can see here, but you'll notice that he only jumps when you release your finger from the UP key. I'd like him to jump immediately the key is pressed, and I'm sure the problem is this: as long as your finger is on the UP key, that line of code is continuously being run, i.e. gotoAndPlay ("leap"); Therefore, he's stuck on the frame labelled 'leap'. When you release your finger however, he jumps away.

Could anyone please tell me how I'd run that piece of code only once? I have tried using a counter variable, but I'm not too good at ActionScript (trying to remedy that) and I'm sure I'm doing everything wrong.

Cheers
.chluaid is offline   Reply With Quote
Old 07-30-2002, 03:28 AM   #2
sumul
What the hell is a sumul?
 
sumul's Avatar
 
Join Date: Apr 2002
Location: USA
Posts: 222
Default

You could try something like ...
ActionScript Code:
onClipEvent(enterFrame) { if(!leaping) {  if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) { leaping = true; gotoAndPlay("leap"); } } }
Then put "leaping = false;" at the end of your leap animation. Of course, if you're using MX, the onKeyDown event would save you some trouble.
sumul is offline   Reply With Quote
Old 07-30-2002, 07:37 AM   #3
.chluaid
Registered User
 
Join Date: Jul 2002
Location: Sydney Australia
Posts: 5
Send a message via ICQ to .chluaid
Default

thanks for your help
your advice was great and I've got it working now..

the bit I don't understand about your reply was the Flash MX onKeyDown event.. Yes I am using Flash MX, but could you tell me something about onKeyDown please? I had no idea it existed.
.chluaid is offline   Reply With Quote
Old 07-30-2002, 07:50 AM   #4
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

Quote:
Originally posted by .chluaid
.. Yes I am using Flash MX, but could you tell me something about onKeyDown please? I had no idea it existed.
http://www.actionscript.org/tutorial...el/index.shtml
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 07-30-2002, 08:37 AM   #5
.chluaid
Registered User
 
Join Date: Jul 2002
Location: Sydney Australia
Posts: 5
Send a message via ICQ to .chluaid
Default

cheers farafiro

reading now
.chluaid is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash Player not in end users computer Andy S Other Flash General Questions 4 05-17-2004 08:10 AM
scrollBar on Flash Exchange cdeg Components 5 05-03-2004 07:13 PM
Position Available: Flash Game Programmer loveboat Projects and Positions 0 08-25-2003 07:49 PM
Hill Billy Whack? Flash Game Help Needed agentfive Projects and Positions 0 04-15-2002 11:19 PM
Flash Player in IE on Mac Problem GDubb ActionScript 1.0 (and below) 0 04-04-2002 04:48 PM


All times are GMT. The time now is 04:00 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.