我想搬到一个数组中产生体育场波效应的所有对象,我该怎么办呢? 我想移动的基础上舞台的y值的对象......我所有的方块是50×50大小的。我想移动起来再往前下来。 下面是我的code,请给我建议。谢谢!
进口fl.transitions.Tween;
进口fl.transitions.easing中*。
进口fl.transitions.TweenEvent;
变种t1的:定时器=新定时器(100,0);
VAR指数:= 0;
t1.addEventListener(TimerEvent.TIMER,平);
t1.start();
VAR阵列:阵列=新的Array();
addToArray();
功能addToArray():无效{
为(变种I = 0; I&小于10;我++){
数组[我] =新的平方();
数组[我] .X = I * 50 + 50;
数组[我] .Y = 100;
的addChild(数组[我]);
}
}
功能平(E:TimerEvent){
如果(指数< array.length){
为moveUp(数组[指数]);
指数++;
}
}
功能为moveUp(SQ:广场):无效{
变种tweenRight:吐温=新吐温(平方米,y的,None.easeOut,sq.y,sq.y - 50,1,真);
tweenRight.addEventListener(TweenEvent.MOTION_FINISH,下移);
}
功能下移(E:TweenEvent):无效{
//放什么在这里?
//或者这是不正确的方式做到这一点?
}
解决方案
您需要抢在下移功能的补间对象和应用补间动画(增加Y)。
函数下移(E:TweenEvent):无效{
VAR平方:平方=平方(e.target.obj);
变种tweenDown:吐温=新吐温(平方米,y的,None.easeOut,sq.y,sq.y + 50,1,真);
如果(SQ(e.target.obj)===阵列[array.length - 1]){
跟踪(这是最后的补降);
tweenDown.addEventListener(TweenEvent.MOTION_FINISH,lastTweenFinish);
}
}
功能lastTweenFinish(E:TweenEvent):无效{
跟踪(DONE);
}
为什么要使用计时器T2在为moveUp功能的一件事。
I want to move all objects in an array producing a stadium wave effect, how do i do that? I want to move the objects based on their y-value on the stage... all my squares are of 50x50 in size. I want to move them up then move them down. Below is my code, please give me advice. Thanks!
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var t1:Timer = new Timer(100, 0);
var index:int = 0;
t1.addEventListener(TimerEvent.TIMER, ping);
t1.start();
var array:Array = new Array();
addToArray();
function addToArray():void {
for(var i=0; i<10; i++) {
array[i] = new Sq();
array[i].x = i*50 + 50;
array[i].y = 100;
addChild(array[i]);
}
}
function ping(e:TimerEvent) {
if(index < array.length){
moveUp(array[index]);
index ++;
}
}
function moveUp(sq:Sq):void{
var tweenRight:Tween = new Tween(sq,"y",None.easeOut, sq.y, sq.y - 50, 1, true);
tweenRight.addEventListener(TweenEvent.MOTION_FINISH, moveDown);
}
function moveDown(e:TweenEvent):void {
//what to put here?
//or this is not the right way to do this?
}
解决方案
You need to grab the tweened object in moveDown function and apply motion tween (increase y).
function moveDown(e:TweenEvent):void {
var sq:Sq = Sq(e.target.obj);
var tweenDown:Tween = new Tween(sq,"y",None.easeOut, sq.y, sq.y + 50, 1, true);
if (Sq(e.target.obj) === array[array.length - 1]) {
trace("this is the last tween down");
tweenDown.addEventListener(TweenEvent.MOTION_FINISH, lastTweenFinish);
}
}
function lastTweenFinish(e:TweenEvent):void {
trace("DONE");
}
One more thing why are you using Timer t2 in moveUp function.
上一篇:如何增加图象到Adobe的Flex使用RichTextEditor?图象、Adobe、RichTextEditor、Flex
下一篇:UserPrincipal.Current返回程序池在IIS程序、UserPrincipal、Current、IIS