Web Design Resources & Tutorials to help you design the best website!
This example is almost a replica of PaperVision3D concrete example with the camera, except that it uses the native API that comes in Flash Player 10 for Flex. Need Flash Player to view it below
Here is an Example, you need to click first with the mouse to bring focus and move with the keys (w,a,s,d)
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:exhdLib="exhdLib.*" paddingTop="30" backgroundColor="0xFFFFFF" creationComplete="initApp()"> <mx:Script> <![CDATA[ import mx.core.UIComponent; private var aKeyDown:Boolean; private var sKeyDown:Boolean; private var dKeyDown:Boolean; private var wKeyDown:Boolean; [Embed(@source="concr.jpg")] private var concretePic:Class; private var concreteHolder:UIComponent = new UIComponent(); private function initApp():void { var bitmap:Bitmap = new concretePic(); bitmap.rotationX=90; bitmap.x = -260; bitmap.y=250; concreteHolder.addChild(bitmap); addChild(concreteHolder); addEventListener(MouseEvent.CLICK,onMouseClick); } private function onMouseClick(event:MouseEvent):void { concreteHolder.setFocus(); addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown); addEventListener(KeyboardEvent.KEY_UP,onKeyUp); addEventListener(Event.ENTER_FRAME,onEnterFrame); } private function onKeyDown(event:KeyboardEvent):void { // W: 87 , A: 65, S: 83 , D: 68 switch(event.keyCode) { case 87: wKeyDown=true; break; case 65: aKeyDown=true; break; case 83: sKeyDown=true; break; case 68: dKeyDown =true; break; } } private function onKeyUp(event:KeyboardEvent):void { switch(event.keyCode) { case 87: wKeyDown=false; break; case 65: aKeyDown=false; break; case 83: sKeyDown=false; break; case 68: dKeyDown =false; break; } } private function onEnterFrame(event:Event):void { if(aKeyDown) concreteHolder.rotationY+=10; if(sKeyDown) concreteHolder.z+=10; if(dKeyDown) concreteHolder.rotationY-=10; if(wKeyDown) concreteHolder.z-=10; } ]]> </mx:Script> </mx:Application>

4 Responses to Simulating the Camera Effect in Flex using Flash Player 10
bluemetal
June 4th, 2008 at 7:14 pm
rotation center looks always same position
Mihail Mirchev
August 29th, 2008 at 12:50 am
What if I want to “look” up/down and then left/right?
Sherif
August 29th, 2008 at 1:01 am
Then You could Play around with rotationX and RotationY and rotationZ
daemonna
May 28th, 2009 at 1:35 pm
great! finally dont need papervision and other frameworks