spark下_3D翻转特效(二)

时间:2021-03-02 08:46:26

一.基本讲解

1.   将DistortionEffects.swc文件拷贝到lib文件夹中

2.   引入需要用到的类库xmlns:mxeffects="com.adobe.ac.mxeffects.*"

3.   导入需要用到的类:DistortionConstants,Flip

import com.adobe.ac.mxeffects.DistortionConstants;

import com.adobe.ac.mxeffects.Flip;

4. 在时间的方法里面编写特效的关键代码:

n  创建Flip类的实例传递一个参数(当前对象的id)

n  指定目标对象的集合e.siblings = [ registration ];

n  指定旋转的方向e.direction = DistortionConstants.RIGHT;

n  指定旋转的时间短e.duration = 2000;

n  开发播放e.play();

二.源代码

<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                       xmlns:s="library://ns.adobe.com/flex/spark"

                       xmlns:mx="library://ns.adobe.com/flex/mx"

                       xmlns:_3dcomp="_3dcomp.*"

                       xmlns:mxeffects="com.adobe.ac.mxeffects.*"

                       width="466" height="370">

   

    <fx:Script>

        <![CDATA[

            import com.adobe.ac.mxeffects.DistortionConstants;

            import com.adobe.ac.mxeffects.Flip;

            protected function login1_changeHandler(event:Event):void

            {

                var e : Flip = new Flip( one );

                e.siblings = [ two ];

                e.direction = DistortionConstants.RIGHT;

                e.duration = 2000;

                e.play();

            }

            protected function regi1_changeHandler(event:Event):void

            {

                var e : Flip = new Flip( two );

                e.siblings = [ one ];

                e.direction = DistortionConstants.LEFT;                

                e.duration = 2000;

                e.play();  

            }

        ]]>

    </fx:Script>

   

    <mx:ViewStack id="viewstack1" width="322" height="300" horizontalCenter="0" verticalCenter="0">

       

        <s:NavigatorContent width="100%" height="100%" label="视图 1"  id="one">

            <s:Panel left="5" right="5" top="5" bottom="5" title="http://blog.csdn.net/fly_air.com">

        <s:Button bottom="20" label="按钮" horizontalCenter="0" click="login1_changeHandler(event)"/>

        <s:Label fontSize="25" fontWeight="bold" horizontalCenter="0" text="第一个"

                         verticalCenter="0"/>

            </s:Panel>

        </s:NavigatorContent>

        <s:NavigatorContent width="100%" height="100%" label="er" id="two">

            <s:Panel left="5" right="5" top="5" bottom="5" title="http://blog.csdn.net/fly_air.com">

                <s:Button bottom="20" label="按钮" horizontalCenter="0" click="regi1_changeHandler(event)"/>

        <s:Label fontSize="25" fontWeight="bold" horizontalCenter="0" text="第二个"

                         verticalCenter="0"/>

            </s:Panel>

        </s:NavigatorContent>

    </mx:ViewStack>

</s:WindowedApplication>

 

三.预览

spark下_3D翻转特效(二)spark下_3D翻转特效(二)