Rotating forth/back with AS

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

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.

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…

This is also and option:


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