Web Design Resources & Tutorials to help you design the best website!
Here is yet another example of creating a free rotating plane and having two different images one in the back and one in the front. Need Flash Player 10 to view it.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="500" backgroundColor="0x000000" color="0x000000"> <mx:Script> <![CDATA[ import mx.core.UIComponent; import mx.controls.Image; [Embed(@source="images/Dock.jpg")] private var frontImageClass:Class; [Embed(@source="images/Garden.jpg")] private var backImageClass:Class; private var frontImage:Image; private var backImage:Image; private var contentHolder:UIComponent; private var contentCreated:Boolean; protected override function createChildren():void { super.createChildren(); frontImage = new Image(); backImage = new Image(); contentHolder = new UIComponent(); frontImage.load(frontImageClass); backImage.load(backImageClass); addChild(contentHolder); contentHolder.addChild(frontImage); contentHolder.addChild(backImage); contentCreated=true; } protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); if(contentCreated) { backImage.width=frontImage.width=250; backImage.height=frontImage.height=250; backImage.x = frontImage.x-= frontImage.width * .5; backImage.y =frontImage.y-= frontImage.height*.5; //if we do not do this then the whole thing screws up //i do not know why but we have to push one image backwards backImage.z=1; //center it contentHolder.x = 250; contentHolder.y=250; contentCreated=false; addEventListener(Event.ENTER_FRAME,onEnterFrame); } } private function onEnterFrame(event:Event):void { contentHolder.rotationY-=8.5; var currentRotationPlacement:Number = (-contentHolder.rotationY) % 360; if(currentRotationPlacement > 90 && currentRotationPlacement < 270) { backImage.visible=true; frontImage.visible=false; } else { backImage.visible=false; frontImage.visible=true; } } ]]> </mx:Script> </mx:Application>

2 Responses to Two Sided 3D Image Plane in Flex
Devon O.
June 6th, 2008 at 6:15 pm
Quite similar to the method I used a couple weeks ago: http://blog.onebyonedesign.com/?p=66
Daniel H.
March 19th, 2009 at 2:48 pm
Hey- I'm trying to implement this (I'm actually going to see if I can get it to flip on mouseover) but even just copying your code and changing the images, all I get is a black screen. I changed the background color and that worked, so something is TRYING to work, but I never get the animation. I'm using the flex4sdk and flash player 10, but I'm not having any luck. Any ideas?