PDA

View Full Version : simple AS movement question



Inflicted
October 14th, 2003, 09:49 AM
I'm doing a tut to learn animation through AS,
but can't figure out how to stop the MC

onClipEvent (enterFrame) {
speed = -2;
this._y += speed;
}

Anyone?

regards

thebigcheese
October 14th, 2003, 11:15 AM
you can add to that code to make it like this:

onClipEvent (enterFrame) {
speed = -2;
this._y += speed;

if(this._y > 500) {//change 500 to the greatest value the _y value can be
delete this.onClipEvent(enterFrame)
}
}


Im pretty sure that would work - ive use it before

Inflicted
October 14th, 2003, 11:27 AM
Thanks, and what if I want the MC to perform another action, for instance move right?

regards

lostinbeta
October 14th, 2003, 12:10 PM
Theres a few problems with your code thebigcheese onClipEvent (enterFrame) {
speed = -2;
this._y += speed;
//since speed is -2 the clip will never be > 500
if(this._y > 500) {//change 500 to the greatest value the _y value can be
//you cannot delete a static event handler
delete this.onClipEvent(enterFrame)
}
}

So instead you can do... onClipEvent (enterFrame) {
speed = -2;
this._y += speed;
if (this._y<=0) {
this._y = 0;
}
}

Inflicted: To get it to move right just do the same thing but instead of using _y use _x.

Inflicted
October 14th, 2003, 12:27 PM
Thanks lostinbeta!

I already noticed the code didn't work.
Could you help me with my second question:
I want the MC to move to the right after it has stopped.

Hope you can help me, trying to improve my AS.

regards

lostinbeta
October 14th, 2003, 12:33 PM
LOL... sorry I just called you Lunatic (edited my last post to show right now)... I had two threads opened and got myself all mixed up :P

onClipEvent (enterFrame) {
speed = 2;
this._y -= speed;
if (this._y<=0) {
this._y = 0;
this._x += 2;
if (this._x >= 300){
this._x = 300;
}
}
}

Something like that should work (untested)

As you see, if you are just trying to do something like this you are better off tweening (AS Motion isn't always better than tweens) otherwise you are going to end up with a ton of nested if statements and a migrain the size of the Atlantic Ocean.

Inflicted
October 14th, 2003, 12:39 PM
O.K.,
I thought tweening took a lot of memory, so I wanted to try it the "AS" way.
So for complex MC movement tweening is a better option you think? It's a lot easier for me to do, that's for sure!

Oh, and I didn't see you calling me lunatic, well maybe I am...

regards

lostinbeta
October 14th, 2003, 12:42 PM
Yeah, for something like this it seems tweens would be an easier and better route.

Inflicted
October 14th, 2003, 12:50 PM
Thanks,

Check my panda here:

www.inflicted.nl/a-desire-to-fail.html

regards

lostinbeta
October 14th, 2003, 04:44 PM
Wow that's very nice Inflicted... excellent job.

Inflicted
October 14th, 2003, 04:58 PM
Cheers...!

lunatic
October 14th, 2003, 05:22 PM
Dudes. . . leave me out of this


heh heh ;)

Inflicted
October 14th, 2003, 05:33 PM
How did you find out your name turned up in this thread?!
lunatic is a Jedi!!!!

regards

lostinbeta
October 14th, 2003, 05:39 PM
Quick shove lunatic in a potato sack and send him rolling down a hill, he knows too much!!!!!

lunatic
October 14th, 2003, 05:40 PM
That's funny - my students in a cartography class that I was T.A. for used to call me Yoda (note to self: need Yoda smiley). But that was more due to a very (very) late night in the lab when we started using silly voices to communicate. :rd:

Actually it was simple to find my name - it's called being horribly bored at a job I don't really like! heh heh

:hr: <-- hey it's me!

lostinbeta
October 14th, 2003, 05:42 PM
Originally posted by lunatic
:hr: <-- hey it's me!

No, actually it's me :P ... it's the old smiley I made for myself, but that was replaced with http://www.lostinbeta.com/banner/pixelLost.gif so I let Kirupa add the old one to the smiley list.

lunatic
October 14th, 2003, 05:43 PM
Sweet! How do you make a smiley anyway?

lostinbeta
October 14th, 2003, 05:45 PM
I took the original :) smiley and then brought it into photoshop, took a 1px pencil tool, zoomed all the way and colored over the facial features with the proper yellows then I chose my own colors and click away to make the facial features and hair pixel by pixel.

Inflicted
October 14th, 2003, 05:48 PM
Well lunatic,

If you're bored, got a nice thread for ya:

http://www.flashkit.com/board/showthread.php?threadid=499270

Help me out! I need solution badly...
Else ask Obi Wan

regards

lunatic
October 14th, 2003, 05:53 PM
I take it you posted it here and got no answers?

Dude, wish I could help you, but I am a just a Jedi in training. I'm sure someone with better access to the Force will find you.

:blush: