moving a box!

  • hamid_r_h
  • Born
  • Born
  • No Avatar
  • Joined: Jan 30, 2004
  • Posts: 2
  • Status: Offline

Post February 7th, 2004, 10:57 pm

I 'm trying to learn Flash and actionscript


now I want when the user press and release the left arrow a box(Move Clip) moves to left and countinue to move left when the user press right arrow the box moves to right and countinue to move right and same thing for up and down.
I wrote a script for it.
but I dont think it is the best way.
does any one know a better way?



here's my script:
Code: [ Select ]
onClipEvent (enterFrame) {
    this._x += s;
    if (Key.isDown(Key.Left)) {
        s1 = 0;
        s = -10;
    }
    if (Key.isDown(Key.Right)) {
        s1 = 0;
        s = +10;
    }
}
onClipEvent (enterFrame) {
    this._y += s1;
    if (Key.isDown(Key.Up)) {
        s = 0;
        s1 = -10;
    }
    if (Key.isDown(Key.Down)) {
        s = 0;
        s1 = +10;
    }
}
  1. onClipEvent (enterFrame) {
  2.     this._x += s;
  3.     if (Key.isDown(Key.Left)) {
  4.         s1 = 0;
  5.         s = -10;
  6.     }
  7.     if (Key.isDown(Key.Right)) {
  8.         s1 = 0;
  9.         s = +10;
  10.     }
  11. }
  12. onClipEvent (enterFrame) {
  13.     this._y += s1;
  14.     if (Key.isDown(Key.Up)) {
  15.         s = 0;
  16.         s1 = -10;
  17.     }
  18.     if (Key.isDown(Key.Down)) {
  19.         s = 0;
  20.         s1 = +10;
  21.     }
  22. }
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 7th, 2004, 10:57 pm

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post February 8th, 2004, 12:22 am

Is this like what you're trying to do?

http://www.kirupa.com/developer/actionscript/xymove.htm
http://www.kirupa.com/developer/mx/movement_keys.htm
  • solaris
  • Student
  • Student
  • User avatar
  • Joined: Oct 18, 2003
  • Posts: 83
  • Loc: NC
  • Status: Offline

Post February 8th, 2004, 1:15 am

wonder why ur script is so spaced out :shock:

im stupid hehe 8)
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post February 8th, 2004, 8:29 am

i fixed it for him :)
UNFLUX.FOTO
  • solaris
  • Student
  • Student
  • User avatar
  • Joined: Oct 18, 2003
  • Posts: 83
  • Loc: NC
  • Status: Offline

Post February 8th, 2004, 6:34 pm

looks alot better ;)
  • SycomCOmp
  • Graduate
  • Graduate
  • User avatar
  • Joined: Aug 02, 2003
  • Posts: 173
  • Loc: USA
  • Status: Offline

Post February 24th, 2004, 1:19 pm

I dont know if this was a neccessary post but I just had to say something after viewing your web site...

http://www.solarisdesigns.net/v4/site.html

Very nice but I cant get over how similar it looks like this

http://www.unflux.com
sorry if this was completely off topic I can never keep my mouth shut :P

Do you guys work together? :wink:
ok ok i'm done

later
:arrow: SycomCOmp :idea:
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post February 24th, 2004, 2:20 pm

UNFLUX does not take kindly to rippers.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.