|
-
[RESOLVED] Does localToGlobal work with z coordinate?
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:
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;
};
};
};
};
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.
Any help appreciated!
Cheers.
Last edited by moosefetcher; 10-16-2009 at 04:54 AM.
-
I'm still not 100% this will work, but I've just stumbled across 'local3DToGlobal' which carries all three coordinates from a Vector3D. That should do the trick. Sweet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|