<?xml version="1.0" encoding="utf-8"?>
<s:Group 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="572" height="374">
<fx:Script>
<![CDATA[
import spark.effects.Move;
/**每次要移动的长度*/
private var moveLength:Number = 50;
/**动画对象*/
private var myMove:Move = new Move();
/**上移**/
protected function topMove(event:MouseEvent):void
{
//移动对象(控件)
myMove.target=lblMove;
//移动时间间隔0.5s
myMove.duration = 500;
//目的地的x值
myMove.xTo=lblMove.x;
//目的地的y值
myMove.yTo=lblMove.y-moveLength;
//开始动画
myMove.play();
}
/**下移*/
protected function downMove(event:MouseEvent):void
{
myMove.target=lblMove;
myMove.duration = 500;
myMove.xTo=lblMove.x;
myMove.yTo=lblMove.y+moveLength;
myMove.play();
}
/**左移*/
protected function leftMove(event:MouseEvent):void
{
myMove.target=lblMove;
myMove.duration = 500;
myMove.xTo=lblMove.x-moveLength;
myMove.yTo=lblMove.y;
myMove.play();
}
/**右移*/
protected function rightMove(event:MouseEvent):void
{
myMove.target=lblMove;
myMove.duration = 500;
myMove.xTo=lblMove.x+moveLength;
myMove.yTo=lblMove.y;
myMove.play();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button x="68" y="46" label="上移" click="topMove(event)"/>
<s:Button x="153" y="46" label="下移" click="downMove(event)"/>
<s:Button x="233" y="46" label="左移" click="leftMove(event)"/>
<s:Button x="320" y="46" label="右移" click="rightMove(event)"/>
<s:Label id="lblMove" x="201" y="169" text="移动对象"/>
</s:Group>
Flex页面组件滑动
最新推荐文章于 2024-03-18 18:36:08 发布