PDA

View Full Version : Animation using actionscript


LocoDave
05-10-2004, 08:34 AM
Hi Guys, just wondering if anyone know how i can animate sumpin like the fla provided by using actionscript instead of frame animation!

I just want an object to go across the screen and then loop again once it has reached the end point again.

Ive looked at the grass tutorial (kirupa sample), but couldnt get my head around it.

Thanks for ur help

pom
05-10-2004, 08:38 AM
Hi,

I didn't look at your file, but you could do something like that:from = 50 ;
to = 400 ;
speed = 10 ;
theClip.onEnterFrame = function () {
this._x += speed ;
if (this._x > to) this._x = from ;
} ;

pom
05-10-2004, 08:43 AM
This might work too:from = 50 ;
to = 400 ;
speed = 10 ;
theClip.onEnterFrame = function () {
this._x = (this._x + speed) % (to - from) + from ;
} ;I said might work :)

LocoDave
05-10-2004, 10:28 AM
thanks for ur code! got it working! just one thing, it flashs every now and then? why is that? it's not a full smooth animation, is that because it is actionscript rather then animated??

Thanks for ur help

here is the fla if u wanna see the flash im talking about!!

cobo
05-10-2004, 10:35 AM
maybe your frame rate is to low...

if you use onEnterFrame, speed will always depend of your personal frame rate...

give it a try with setInterval to launch the function by time intervals...

cobo

LocoDave
05-10-2004, 10:40 AM
hey there, i tried the setInterval, and it didnt work, the mc didnt scroll across the page, it just flashed on the other end!!

pom
05-11-2004, 07:20 AM
Yes, use a higher frame rate, or decrease the speed :)

arch
07-16-2004, 04:55 PM
it's flashing because the circle movie clip has a single frame where you set it way off center.

jsam
07-23-2004, 11:37 AM
Hi,
Edit ur circle mc,
remove all the frames except frame 1
run ur movie.
Now ur bug is fixed.


Yeee.......