<?xml version="1.0" encoding="utf-8"?>
<FxApplication name="FxRotation3D_test"
xmlns="http://ns.adobe.com/mxml/2009"
initialize="init();"
viewSourceURL="srcview/index.html">
<layout>
<BasicLayout />
</layout>
<Script>
<![CDATA[
import mx.components.FxButton;
import mx.components.VGroup;
import mx.controls.Image;
import mx.effects.FxRotate3D;
[Embed("assets/fx_appicon.jpg")]
private const FlexLogo:Class;
private var fxButtonX:FxButton;
private var fxButtonY:FxButton;
private var fxButtonZ:FxButton;
private var fxRotate3DX:FxRotate3D;
private var fxRotate3DY:FxRotate3D;
private var fxRotate3DZ:FxRotate3D;
private var image:Image;
private function init():void {
fxRotate3DX = new FxRotate3D();
fxRotate3DX.xFrom = 0;
fxRotate3DX.xTo = 360;
fxRotate3DX.duration = 2000;
fxRotate3DY = new FxRotate3D();
fxRotate3DY.yFrom = 0;
fxRotate3DY.yTo = 360;
fxRotate3DY.duration = 2000;
fxRotate3DZ = new FxRotate3D();
fxRotate3DZ.zFrom = 0;
fxRotate3DZ.zTo = 360;
fxRotate3DZ.duration = 2000;
fxButtonX = new FxButton();
fxButtonX.label = "FxRotate3D X-axis";
fxButtonX.addEventListener(MouseEvent.CLICK, fxButtonX_click);
fxButtonY = new FxButton();
fxButtonY.label = "FxRotate3D Y-axis";
fxButtonY.addEventListener(MouseEvent.CLICK, fxButtonY_click);
fxButtonZ = new FxButton();
fxButtonZ.label = "FxRotate3D Z-axis";
fxButtonZ.addEventListener(MouseEvent.CLICK, fxButtonZ_click);
var vGroup:VGroup = new VGroup();
vGroup.setStyle("left", 10);
vGroup.setStyle("top", 10);
vGroup.addItem(fxButtonX);
vGroup.addItem(fxButtonY);
vGroup.addItem(fxButtonZ);
addItem(vGroup);
image = new Image();
image.source = FlexLogo;
image.width = 100;
image.height = 100;
image.setStyle("horizontalCenter", 0);
image.setStyle("verticalCenter", 0);
addItem(image);
}
private function fxButtonX_click(evt:MouseEvent):void {
fxRotate3DX.play([image]);
trace("3x");
}
private function fxButtonY_click(evt:MouseEvent):void {
fxRotate3DY.play([image]);
trace("3y");
}
private function fxButtonZ_click(evt:MouseEvent):void {
fxRotate3DZ.play([image]);
trace("3z");
}
]]>
</Script>
</FxApplication>