Here's a sample .fla to start you off.
There is a single movieclip in the library which is exported as 'diamond' which looks like a diamond on it's side.
Here's the script:
code:
kCenterX = Stage.width/2;
kCenterY = Stage.height/2;
kSpinSpeed = .0005; // controls speed of rotation
kPulseSpeed = .001; // controls speed of expansion/contraction
kMinAmplitude = 50; // controls minimum contraction distance
kMaxAmplitude = 200; // controls maximum contraction distance
kDiamondSize = 50; // controls overall diamond size
moveDiamond = function()
{
// a (angle) is the position on the circle
a = this.phase + getTimer()*kSpinSpeed;
// rad is the distance the diamond will be drawn from the center
rad = kMinAmplitude + Math.sin(getTimer()*kPulseSpeed)*(kMaxAmplitude - kMinAmplitude);
this._x = kCenterX + Math.cos(a)*rad;
this._y = kCenterY + Math.sin(a)*rad;
// we set our rotation to corespond to our angle
this._rotation = a*180/Math.PI;
}
// this is the loop where we setup the diamonds
for (i = 0; i < 5; ++i)
{
var mc = _root.attachMovie('diamond', 'diamond_' + i, i);
// each diamond is given a phase offset corresponding to 1/5 if the circle - so they spread out around the circle
mc.phase = i*2*Math.PI/5;
// this assigns the animation function for each diamond - it is called each frame
mc.onEnterFrame = moveDiamond;
// i drew my diamonds too large, so here I reduce their size
mc._xscale = mc._yscale = kDiamondSize;
}
You can also create additional sets of 5 diamonds which have different colors, and an offset added to the phase, to cause them to be interleaved with the others.




Reply With Quote