I am creating an animation for a client. I have images of a statue from different angles. I am rotating the images in ‘3D’, similar to a merry-go-round or how the planets circle the sun.
I have five separate images, all separated equally by degrees on the circle path (orbit, if you will)
Here is the actionscript for one of the statues
onClipEvent(load){
y=200;
speed=1;
radius=200;
xcenter=275;
ycenter=0;
zcenter=200;
angle=288;
fl=300;
}
onClipEvent(enterFrame){
z=Math.sin(angle*Math.PI/180)*radius+zcenter;
scale=fl/(fl+z);
x=Math.cos(angle*Math.PI/180)*radius;
_x=x*scale+xcenter;
_y=y*scale+ycenter;
_xscale= _yscale = scale*100;
angle+=speed;
if(angle>359){
angle-=360;
}
if((zcenter<200) && (zcenter>0)) {
this.swapDepths=("back-left1", -4);
} else {
this.swapDepths=("back-left1", getNextHighestDepth());
}
}
Each image is on its own layer on the stage inside the same swf/fla. I’m using the actionscript to animate them. It works, however, I’m having issues with swapping with layers.
Basically, imagine that the images are like planets orbiting the sun (the sun would be the center point of the z axis). Right now, the layers are determined by the stacking order I have in the fla file. So, when the first images moves in front of the ‘sun’ - it should be the top layer, and then, when it circles behind the ‘sun’ - it should go to the bottom layer. I need the image to be the top layer for 180 degrees, and then the bottom layer (when it goes behind the ‘sun’) for 180 degrees.
The image also needs to be behind the next images starting to circle the front of the ‘sun’. (remember, I’m using the word ‘sun’ as the center of the z axis).
The above code is placed on the instance of the first movie clip which contains the first statue image. Similar code (with different angles and different swapDepths statements) is placed on each instance for the remaining four movie clips. I have 5 total. (see link for swf file)
I do need to keep the stacking order somewhat intact, based on the order the statues rotate - but I do need for each one to go to a different lower layer when going behind the ‘sun’ and then moving up to a higher layer when going in front of the ‘sun’.
Any assistance would be greatly appreciated.
Thank you!