Flex-rotate3d-effect

提供:Dev Guides
移動先:案内検索

フレックス-Rotate3Dエフェクト

前書き

Rotate3Dクラスは、x、y、またはz軸を中心に3次元でターゲットオブジェクトを回転します。 回転は、ターゲットの変換中心を中心に発生します。

クラス宣言

以下は spark.effects.Rotate3D クラスの宣言です-

public class Rotate3D
   extends AnimateTransform3D

パブリックプロパティ

Sr.No Property & Description
1

angleXFrom : Number

X軸を中心としたターゲットオブジェクトの回転の開始角度(度単位)。

2

angleXTo : Number

x軸の周りのターゲットオブジェクトの回転の終了角度(度単位)。

3

angleYFrom : Number

y軸を中心としたターゲットオブジェクトの回転の開始角度(度単位)。

4

angleYTo : Number

y軸を中心としたターゲットオブジェクトの回転の終了角度(度単位)。

5

angleZFrom : Number

z軸を中心としたターゲットオブジェクトの回転の開始角度(度単位)。

6

angleZTo : Number

z軸を中心としたターゲットオブジェクトの回転の終了角度(度単位)。

パブリックメソッド

Sr.No Method & Description
1

Rotate3D(target:Object = null)

コンストラクタ。

継承されるメソッド

このクラスは、次のクラスからメソッドを継承します-

  • spark.effects.AnimateTransform3D
  • spark.effects.AnimateTransform
  • spark.effects.Animate
  • mx.effects.Effect
  • flash.events.EventDispatcher
  • 対象

Flex Rotate3Dエフェクトの例

テストアプリケーションを作成して、FlexアプリケーションでRotate3Dエフェクトの使用を確認するには、次の手順に従います-

Step Description
1 Create a project with a name HelloWorld under a package com.finddevguides.client as explained in the Flex - Create Application chapter.
2 Modify HelloWorld.mxml as explained below. Keep rest of the files unchanged.
3 Compile and run the application to make sure business logic is working as per the requirements.

以下は、変更されたmxmlファイル src/com.finddevguides/HelloWorld.mxml の内容です。

<?xml version = "1.0" encoding = "utf-8"?>
<s:Application xmlns:fx = "http://ns.adobe.com/mxml/2009"
   xmlns:s = "library://ns.adobe.com/flex/spark"
   xmlns:mx = "library://ns.adobe.com/flex/mx
   width = "100%" height = "100%" minWidth = "500" minHeight = "500">

   <fx:Style source = "/com/finddevguides/client/Style.css"/>
   <fx:Script>
      <![CDATA[
         private function applyRotateProperties():void {
            rotateEffect.play();
         }
      ]]>
   </fx:Script>

   <fx:Declarations>
      <s:Rotate3D id = "rotateEffect" target = "{imageFlex}"
         angleXFrom = "0.0" angleXTo = "{Number(rotateX.text)}"
         angleYFrom = "0.0" angleYTo = "{Number(rotateY.text)}"
         angleZFrom = "0.0" angleZTo = "{Number(rotateZ.text)}"
        />
   </fx:Declarations>

   <s:BorderContainer width = "630" height = "480" id = "mainContainer"
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50"
         horizontalAlign = "center" verticalAlign = "middle">
         <s:Label id = "lblHeader" text = "Effects Demonstration"
            fontSize = "40" color = "0x777777" styleName = "heading"/>

         <s:Panel id = "rotate3DPanel" title = "Using Rotate3D Effect"
            width = "500" height = "300">
            <s:layout>
               <s:HorizontalLayout  gap = "10" verticalAlign = "middle"
                  horizontalAlign = "center"/>
            </s:layout>

            <s:VGroup top = "10" left = "15">
               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By X:" width = "70"/>
                  <s:TextInput id = "rotateX" text = "45.0" width = "50"/>
               </s:HGroup>

               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By Y:" width = "70"/>
                  <s:TextInput id = "rotateY" text = "15.0" width = "50"/>
               </s:HGroup>

               <s:HGroup verticalAlign = "middle">
                  <s:Label text = "Rotate By Z:" width = "70"/>
                  <s:TextInput id = "rotateZ" text = "15.0" width = "50"/>
               </s:HGroup>

               <s:Button label = "Apply Properties"
                  click = "applyRotateProperties()"/>
            </s:VGroup>

            <s:Image id = "imageFlex"
               source = "http://www.finddevguides.com/images/flex-mini.png"
               height = "200" width = "200"/>
         </s:Panel>
      </s:VGroup>
   </s:BorderContainer>
</s:Application>

すべての変更が完了したら、link:/flex/flex_create_application [Flex-アプリケーションの作成]の章で行ったように、アプリケーションを通常モードでコンパイルして実行します。 アプリケーションに問題がない場合は、次の結果が生成されます。

Flex Rotate3Dエフェクト