

Flash Player 10 : rotation (x,y,z) properties example
source link: http://www.mikechambers.com/blog/2008/08/25/flash-player-10-rotation-xyz-properties-example/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Flash Player 10 : rotation (x,y,z) properties example
Monday, August 25, 2008
One of the new ActionScript APIs include in Flash Player 10 is the addition of z based properties (joining the existing x and y). The DisplayObject.z and DisplayObject.rotationZ properties allow you to manipulate your display object on the z axis (relative to the 3D parent container).
Below is a simple example that shows how changing the rotationX, rotationY and rotationZ properties affect a DisplayObject instance.
The UI is in Flex, but of course, the APIs also work in Flash Authoring. The example requires the Flash Player 10 RC release from labs.
Here is the code for the application (basically just sets the properties for the sprites):
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
backgroundColor="0xFFFFFF"
creationComplete="onCreationComplete()"
>
<mx:Script>
<![CDATA[
[Embed(source="graphics.swf", symbol="logo")]
[Bindable]
private var logoClass:Class;
private function onCreationComplete():void
{
frameRateSlider.value = systemManager.stage.frameRate;
}
private function onValueChange(e:Event):void
{
var slider:HSlider = HSlider(e.target);
switch(slider)
{
case rotationXSlider:
{
logo.rotationX = slider.value;
break;
}
case rotationYSlider:
{
logo.rotationY = slider.value;
break;
}
case rotationZSlider:
{
logo.rotationZ = slider.value;
break;
}
}
}
private function onAnimateSelect():void
{
if(animateXCB.selected || animateYCB.selected ||
animateZCB.selected)
{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
return;
}
if(!animateXCB.selected && !animateYCB.selected &&
!animateZCB.selected)
{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
return;
}
}
private var xDirection:int = 1;
private function onEnterFrame(e:Event):void
{
if(animateXCB.selected)
{
animateSlider(rotationXSlider, "rotationX");
}
if(animateYCB.selected)
{
animateSlider(rotationYSlider, "rotationY");
}
if(animateZCB.selected)
{
animateSlider(rotationZSlider, "rotationZ");
}
}
private function animateSlider(slider:HSlider, property:String):void
{
if(logo[property] == 180)
{
logo[property] = -180;
}
else
{
logo[property] += 2;
}
slider.value = logo[property];
}
private function onFrameRateChange():void
{
stage.frameRate = Math.ceil(frameRateSlider.value);
}
]]>
</mx:Script>
<mx:Panel layout="absolute" right="10" left="10" top="10" bottom="10"
title="DisplayObject Z Properties Example"
color="#000000" height="619">
<mx:Label text="rotationX" left="10" bottom="4"/>
<mx:Label text="rotationY" left="10" bottom="30"/>
<mx:Label text="rotationZ" left="10" bottom="56"/>
<mx:HSlider left="73" bottom="5" id="rotationXSlider" minimum="-180"
maximum="180" allowTrackClick="true"
value="0"
change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
<mx:HSlider left="73" bottom="36" id="rotationYSlider"
allowTrackClick="true" minimum="-180" maximum="180"
value="0"
change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
<mx:HSlider left="73" bottom="62" id="rotationZSlider"
allowTrackClick="true" minimum="-180" maximum="180"
value="0"
change="onValueChange(event)" liveDragging="true" snapInterval="1"/>
<mx:VRule height="64" bottom="10" left="338"/>
<mx:HRule bottom="82" left="10" right="10"/>
<mx:Image width="200" height="200" id="logo"
source="{logoClass}" horizontalCenter="0" top="150"/>
<mx:Image width="200" height="200" right="9" horizontalCenter="0" top="150"
alpha=".05"
source="{logoClass}"/>
<mx:CheckBox label="Animate" left="239" bottom="54" id="animateZCB" click="onAnimateSelect()"/>
<mx:CheckBox label="Animate" left="239" bottom="28" id="animateYCB" click="onAnimateSelect()"/>
<mx:CheckBox label="Animate" left="239" bottom="2" id="animateXCB" click="onAnimateSelect()"/>
<mx:Label text="Framerate" bottom="4" left="348"/>
<mx:HSlider left="418" bottom="5"
id="frameRateSlider"
liveDragging="true"
allowTrackClick="true" minimum="1" maximum="70"
change="onFrameRateChange()"/>
</mx:Panel>
</mx:Application>
You can find more information on the z and rotationZ properties in the DisplayObject entry in the Flash Player 10 ActionScript APIs docs.
You can find more information on Flash Player 10 on labs.
Recommend
-
18
Macromedia Will Ship Flash Player With Microsoft's New Windows XP By Khanh T.L. Tran and Rebecca Buck...
-
8
Living Without Adobe Flash Player Submitted by NanoDano on Wed, 07/10/2013 - 02:31...
-
13
Clarifications on Flash Player for Mobile Browsers, the Flash Platform, and the Future of Flash Friday, November 11, 2011 I have worked with Flash and been part of the Flash community for about 12 or 13 years (over 10 of tho...
-
14
FlashCamp San Francisco : April 16th : Flash Player 10.1, Flash CS5, Flash Mobile Wednesday, March 10, 2010 I have just posted information about FlashCamp San Francisco,...
-
10
Flash Player 10.1 and Windows Phone 7 Tuesday, March 9, 2010 There has been a lot of buzz in the mobile space lately, and I suspect there will be even more around Windows Ph...
-
7
Flash Player content, Mouse Events, and Touch input Monday, February 22, 2010 So, the Interwebs is all a buzz again around the latest
-
13
Updates to Flash Player Public Bug Base Wednesday, February 10, 2010 You may have noticed that since September, the public Flash Platform (Flash Player, Flex, etc…) bug base has req...
-
11
Flash Player 10 System Requirements Updated Tuesday, September 15, 2009 Just a quick note, but we have updated the Flash Player 10 System requirements...
-
13
What new game APIs do you want in the Flash Player? Tuesday, June 16, 2009 I have been learning some game development lately, and building my first game (well, at least my first game since Flash 4). I think game develop...
-
2
Video player rotation — interaction vs accessibilityWorking with WCAG 2.1 — 1.3.4
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK