Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-25-2003, 09:58 AM   #1
Shashank
Registered User
 
Shashank's Avatar
 
Join Date: Mar 2003
Posts: 84
Question Key Capture

Iam using the following command...to capture the key and move the object,
now i want to move it only on certain area,
for now its moving out of the scen,

i want to restrict it to certain area.

the code i use on the movie clip to move is onClipEvent (keyDown) {
if (Key.isDown(key.LEFT)) {
_x -= 4;
}
}
onClipEvent (keyDown) {
if (Key.isDown(key.RIGHT)) {
_x += 4;
}
}
onClipEvent (keyDown) {
if (Key.isDown(key.UP)) {
_y -= 4;
}
}
onClipEvent (keyDown) {
if (Key.isDown(key.DOWN)) {
_y += 4;
}
}


can some one help in this

thankx...

Shashank is offline   Reply With Quote
Old 03-25-2003, 10:16 AM   #2
catbert303
member
 
catbert303's Avatar
 
Join Date: Nov 2002
Location: uk
Posts: 428
Default

ActionScript Code:
onClipEvent (keyDown) {     if (Key.isDown(Key.LEFT)) {         if (_x > 10) {             _x -= 4;         }     } else if (Key.isDown(Key.RIGHT)) {         if (_x < 490) {             _x += 4;         }     }     if (Key.isDown(Key.UP)) {         if (_y > 10) {             _y -= 4;         }     } else if (Key.isDown(Key.DOWN)) {         if (_y < 390) {             _y += 4;         }     } }

if you use MX you could determine the limits of how far the clip can move based on Stage.width and Stage.height (instead of hardcoded in the numbers)
catbert303 is offline   Reply With Quote
Old 03-25-2003, 11:20 AM   #3
Shashank
Registered User
 
Shashank's Avatar
 
Join Date: Mar 2003
Posts: 84
Default Key Capture

Thanks for the script/

it really helped me a loot
Shashank 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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:20 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.