A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Does localToGlobal work with z coordinate?

Threaded View

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    47

    resolved [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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center