- Adobe Flex 教程
- Flex - 首页
- Flex - 概述
- Flex - 环境
- Flex - 应用程序
- Flex - 创建应用程序
- Flex - 部署应用程序
- Flex - 生命周期阶段
- Flex - 使用 CSS 样式
- Flex - 使用皮肤样式
- Flex - 数据绑定
- Flex - 基本控件
- Flex - 表单控件
- Flex - 复杂控件
- Flex - 布局面板
- Flex - 视觉效果
- Flex - 事件处理
- Flex - 自定义控件
- Flex - RPC 服务
- Flex - FlexUnit 集成
- Flex - 调试应用程序
- Flex - 国际化
- Flex - 打印支持
- Adobe Flex 资源
- Flex - 快速指南
- Flex - 有用资源
- Flex - 讨论
Flex - 动画属性效果
简介
此动画效果在值之间对任意一组属性进行动画处理。通过设置 motionPaths 属性来指定要进行动画处理的属性和值。
类声明
以下是 spark.effects.Animate 类的声明:
public class Animate extends Effect
公共属性
| 序号 | 属性及描述 |
|---|---|
| 1 | disableLayout : Boolean 如果为 true,则效果会禁用其目标父容器上的布局,将容器的 autoLayout 属性设置为 false,并禁用目标对象上的任何布局约束。 |
| 2 | easer : IEaser 此效果的缓动行为。 |
| 3 | interpolator : IInterpolator 此效果用来计算属性的起始值和结束值之间值的插值器。 |
| 4 | motionPaths : Vector.<MotionPath> MotionPath 对象的向量,每个对象都包含正在进行动画处理的属性的名称以及属性在动画期间获取的值。 |
| 5 | repeatBehavior : String 重复效果的行为,这意味着 repeatCount 等于 0 或 > 1 的效果。 |
公共方法
| 序号 | 方法及描述 |
|---|---|
| 1 | Animate(target:Object = null) 构造函数。 |
事件
| 序号 | 事件及描述 |
|---|---|
| 1 | effectRepeat 当效果开始新的重复时分派,对于重复多次的任何效果。 |
| 2 | effectUpdate 每次效果更新目标时分派。 |
继承的方法
此类继承自以下类:
- mx.effects.Effect
- flash.events.EventDispatcher
- Object
Flex 动画效果示例
让我们按照以下步骤在 Flex 应用程序中检查 Animate Effect 的用法,方法是创建一个测试应用程序:
| 步骤 | 描述 |
|---|---|
| 1 | 在包 com.tutorialspoint.client 下创建一个名为 HelloWorld 的项目,如Flex - 创建应用程序章节中所述。 |
| 2 | 修改 HelloWorld.mxml,如下所述。保持其余文件不变。 |
| 3 | 编译并运行应用程序,以确保业务逻辑按要求工作。 |
以下是修改后的 mxml 文件 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 applyAnimateProperties():void {
animateEffect.play();
}
]]>
</fx:Script>
<fx:Declarations>
<s:Animate id = "animateEffect" duration = "750" target = "{mainHGroup}" >
<s:SimpleMotionPath valueFrom = "1" valueTo = "15" property = "gap" />
<s:SimpleMotionPath valueFrom = "0" valueTo = "-50" property = "z" />
</s:Animate>
</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 = "animatePanel" title = "Using Animate"
width = "500" height = "300" >
<s:layout>
<s:VerticalLayout gap = "10" verticalAlign = "middle"
horizontalAlign = "center" />
</s:layout>
<s:Button label = "Start Animation" click = "applyAnimateProperties()" />
<s:HGroup id = "mainHGroup">
<s:BorderContainer width = "50" height = "50"
borderWeight = "2" color = "0x323232" />
<s:BorderContainer width = "50" height = "50"
borderWeight = "2" color = "0x323232" />
<s:BorderContainer width = "50" height = "50"
borderWeight = "2" color = "0x323232" />
</s:HGroup>
</s:Panel>
</s:VGroup>
</s:BorderContainer>
</s:Application>
完成所有更改后,让我们像在Flex - 创建应用程序章节中一样,在普通模式下编译并运行应用程序。如果应用程序一切正常,则将产生以下结果:[ 在线尝试 ]
flex_visual_effects.htm
广告