Flex - Move3D Effect

Advertisements


Introduction

The Move3D class moves a target object in the x, y, and z dimensions. The x, y, and z property specifications of the Move3D effect specify the change in x, y, and z that should occur to the transform center around which the overall transform effect occurs.

Class declaration

Following is the declaration for spark.effects.Move3D class:

public class Move3D
   extends AnimateTransform3D

Public properties

S.N.Property & Description
1xBy : Number
Number of pixels by which to modify the x position of the target.
2xFrom : Number
Initial x position of the target, in pixels.
3xTo : Number
Final x, in pixels.
4yBy : Number
Number of pixels by which to modify the y position of the target.
5yFrom : Number
Initial y position of the target, in pixels.
6yTo : Number
Final y position of the target, in pixels.
7zBy : Number
Number of pixels by which to modify the z position of the target.
8zFrom : Number
Initial z position of the target.
9zTo : Number
Final z position of the target.

Public methods

S.N.Method & Description
1Move3D(target:Object = null)
Constructor.

Methods inherited

This class inherits methods from the following classes:

  • spark.effects.AnimateTransform3D

  • spark.effects.AnimateTransform

  • spark.effects.Animate

  • mx.effects.Effect

  • flash.events.EventDispatcher

  • Object

Flex Move3D Effect Example

Let us follow the following steps to check usage of Move3D Effect in a Flex application by creating a test application:

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

Following is the content of the modified mxml file src/com.tutorialspoint/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/tutorialspoint/client/Style.css"/>
   <fx:Script>
      <![CDATA[
         private function applyMoveProperties():void {
            moveEffect.play();
         }
      ]]>
   </fx:Script>
   <fx:Declarations>
      <s:Move3D id="moveEffect" target="{imageFlex}" 
         xFrom="{imageFlex.x}" xBy="{Number(moveX.text)}" 
         yFrom="{imageFlex.y}" yBy="{Number(moveY.text)}" 
         zFrom="{imageFlex.z}" zBy="{Number(moveZ.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="move3DPanel" title="Using Move3D 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="Move By X:" width="70"/>
                     <s:TextInput id="moveX" text="50" width="50"/>
                  </s:HGroup>   
                  <s:HGroup verticalAlign="middle">
                     <s:Label text="Move By Y:" width="70"/>
                     <s:TextInput id="moveY" text="50" width="50"/>
                  </s:HGroup>
                  <s:HGroup verticalAlign="middle">
                     <s:Label text="Move By Z:" width="70"/>
                     <s:TextInput id="moveZ" text="50" width="50"/>
                  </s:HGroup>
                  <s:Button label="Apply Properties" 
                     click="applyMoveProperties()"/>						
               </s:VGroup>
               <s:Image id="imageFlex" 
                  source="http://www.tutorialspoint.com/images/flex-mini.png"/>					
            </s:Panel>
       </s:VGroup>	 
    </s:BorderContainer>	
</s:Application>

Once you are ready with all the changes done, let us compile and run the application in normal mode as we did in Flex - Create Application chapter. If everything is fine with your application, this will produce following result: [ Try it online ]

Flex Move3D Effect

Advertisements
Advertisements