PDA

View Full Version : Rotating forth/back with AS



Bacizone
August 29th, 2003, 01:23 PM
Hi,

I am still quite new to AS. I'd like to rotate a circle (compass_mc) around its centerpoint slowly forth/back with +/- 45 degree...or better with random degree.

As file size is important, I can not solve it with MotionTween.

Up to this time I applied this code to the MC, which endlessly rotates it:

iranytu_mc.onEnterFrame = function(){
this._rotation+=1;
}

Do you have any idea how to apply that sort of random slow forth/back rotation to the circle with AS?

Many thanks,

Bacizone

billwatson
August 29th, 2003, 02:12 PM
as a start

clip.onEnterFrame = function(){
if(this._rotation<45)
this._rotation+=1;
}

with variations on this you could have any rotation you wanted but i think the use of setInterval is better than onenterframe.

mlk
August 29th, 2003, 02:52 PM
to finish the code:


onClipEvent (load) {
a = 3;
}
onClipEvent (enterFrame) {
if (this._rotation<=45 && this._rotation>=-45) {
this._rotation += a;
} else {
a *= -1;
this._rotation += a;
}
}


works fine - you could add a bit of easing too...

andr.in
August 29th, 2003, 03:03 PM
This is also and option:



onClipEvent (enterFrame) {
d += 0.1;
_rotation = Math.cos(d)*20;
}