View Full Version : simple animation using actionscript
Dave
May 10th, 2004, 09:29 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
:bad:
Pomme_
May 10th, 2004, 10:17 AM
this.onEnterFrame = function(){
//if your MC's x position is less than the size of your Stage
if (myCircle._x < 400){
//myCircle moves 5 pixels on every EnterFrame
myCircle._x += 5
}
//else, ie: your MC's x pos is OVER 400
else {
//move the circle's X pos to -30
myCircle._x = -30
}
}
You name your redball's instance myCircle and you paste the code aformentionned in the first and only frame of your root.
Dave
May 10th, 2004, 11:19 AM
Hey there, thanks for your help, it's working, but it flashs every now and then, would that be because of the movememnt every 5 pixels using actionscript??
i have the fla here for you to see what i mean!!
thanks for ur help
Dave
May 10th, 2004, 11:21 AM
here is the fla
Pomme_
May 10th, 2004, 01:08 PM
:)
it flashes not because of the 5 pixels movement, but because, when you took the animation tween out of your circle, you forgot to delete the last frame (which basically puts the circle 200 pixels away for a 1/25 of a second). If you only use 1 frame in your circle, it won't jump around anymore...
Cheers
Dave
May 11th, 2004, 01:21 AM
Thanks for that!!! just one last question, how about if i have two circles and want to apply diffrent speeds?? How do i go about scripting that??
I have an fla there with two circles just in case!!
Thanks for your help!
Dave
May 11th, 2004, 02:00 AM
It's cool, i have worked it out!! Thanks for all your help :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.