Hey there.
I've got a carousel that holds images and rotates on its vertical (Y) axis (like a merry-go-round).
I need to depth sort the images while the whole carousel rotates. My problem is, as it's the whole carousel that rotates, the individual images' x and z coordinates do not change. I need some way of extracting each image's Z coordinate relative to the stage to find which is nearest. There doesn't appear to be a 3D version of localToGlobal, but is there a way to use it to extract a Z coordinate? Or is there another way to do this?
Here's the main class:
The PictureHolder class just instantiates a number of RotatingImages, which themselves have methods for positioning themselves in a circle, dependent on the carousel's radius and their number in the sequence.Code:package { import flash.display.MovieClip; import flash.events.*; import flash.geom.Point; public class DocumentClass extends MovieClip { var count:int; const numberOfPictures:int = 7; const holderRadius:int = 480; var pictureHolder:PictureHolder; public function DocumentClass():void { pictureHolder = new PictureHolder(numberOfPictures,holderRadius); pictureHolder.x = 350; pictureHolder.y = 200; pictureHolder.z = holderRadius; addChild(pictureHolder); stage.addEventListener(Event.ENTER_FRAME, updateRotation); }; public function updateRotation(e:Event):void { pictureHolder.rotationY +=1; // depth sorting code needs to go here! for (count=0;count<=numberOfPictures-1;count++) { pictureHolder.pictures[count].rotationY -=1; }; }; }; };
Any help appreciated!
Cheers.




Reply With Quote