15 Replies Latest reply on Aug 13, 2006 2:17 PM by microes

# self-pausing rotation

i.m trying to create a 3d rotation much like the widely used carousel only the rotation i desire consist of four upright(90 degrees) movieclips resting on a slanted, 30 degree plane which rotate onEnterFrame or following a tween on a oval like path - then pause for a given number of seconds at the four movieclips positions equal in distance on the plane

function around() {
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
this._xscale = this._yscale = s*100;
this.angle += this._parent.speed;
}

var centerX:Number = Stage.width / 2;
var centerY:Number = Stage.height / 2;
var speed:Number = 0.02;

• ###### 1. Re: self-pausing rotation
You could use something like this:

var count:Number = 0;
function around() {
count++;
if (count<180) {
this._xscale = this._yscale=s*100;
this.angle += this._parent.speed;
}
else if(count == 260){
count = 0;
}
}

It counts upwards every time the function is called. If count is below 180, it rotates the objects. If it's above 180, there's no rotation until count reaches 260, then count is set to 0 and the rotation starts again. You can adjust the numbers to your needs, as the length of the pause (180 until 260) depends on your movie's fps (if you use the onEnterFrame event).

hth,
blemmo
• ###### 2. Re: self-pausing rotation
and to make it appear your movieclips are rotating on a 30 degree slant add the following line after your var s line:

• ###### 3. self-pausing rotation
ok. how would i go about including four different movieclips in the rotation?
• ###### 4. Re: self-pausing rotation
Just assign each MC a different 'angle' value and the around function to its onEnterFrame event, e.g.:

for (var i=0; i<4; i++){
_root["mc"+i].angle = i*90;
_root["mc"+i].onEnterFrame = around;
}

The code assumes that the MCs are called 'mc0', 'mc1' etc. The angle properties will be 0,90,180 and 270; change this as you need.

cheers,
blemmo
• ###### 5. Re: self-pausing rotation
that angle should be in radians:

_root["mc"+i].angle=Math.PI*i/2
• ###### 6. Re: self-pausing rotation
thanks for showing how to individualize the movieclips in the rotation rather than using duplicates.
i.ll be back after i test things.
thanks again!
• ###### 7. Re: self-pausing rotation
it's unnecessary using a separate loop for each movieclip. use a for-loop in around() and use one onEnterFrame() or setInterval() loop.
• ###### 8. self-pausing rotation
could you please provide the working body of code as i.m getting little errors.
• ###### 9. self-pausing rotation
_
• ###### 10. Re: self-pausing rotation
i'm not sure when you want to pause this but use clearInterval() to pause it and setInterval() to restart it:

• ###### 11. self-pausing rotation
ok. however i would like to use four different looking movieclips in the rotation, rather than the same mc incremented.
• ###### 12. Re: self-pausing rotation
you're welcome.