ChainedTweener class : Usage example
package {
import com.yahoo.motion.ChainedTweenerEvent;
import com.yahoo.motion.easing.Quadratic;
import flash.display.Sprite;
import com.yahoo.motion.ChainedTweener
import flash.filters.GlowFilter
/**
* ...
* @author mr.hichem aka halfrobot
*/
public class ChainedTweener_Example extends Sprite{
private var square:Sprite
private var tweener:ChainedTweener
public function ChainedTweener_Example()
{
createSquare()
square.x = square.y = 0
tweener= new ChainedTweener(square, new Array("x","y"))
tweener.loop = true
tweener.ease = Quadratic.easeOut
tweener.delay = 1000
tweener.addEventListener(ChainedTweenerEvent.MOTION_START, _onStart)
tweener.addEventListener(ChainedTweenerEvent.CHAINED_MOTION_FINISH, _onPartialFinish)
tweener = tweener.chainedTweenFromTo(new Array(50, 50), new Array(200, 50)).chainedTweenTo(new Array(200, 200)).chainedTweenTo(new Array(50,200)).chainedTweenTo(new Array(50,50))
}
private function _onPartialFinish(e:ChainedTweenerEvent)
{
trace("one finished")
}
private function _onFinish(e:ChainedTweenerEvent)
{
trace("all finished")
}
private function _onStart(e:ChainedTweenerEvent)
{
trace("started")
}
private function createSquare()
{
square = new Sprite()
square.graphics.beginFill(0x555555, 1)
square.graphics.lineStyle(5,0xff0099)
square.graphics.drawRoundRect(-25, -25, 50, 50, 10, 10)
square.graphics.endFill()
square.filters = new Array(new GlowFilter(0x000000,0.5,6,6,,2))
this.addChild(square)
square.x = stage.stageWidth / 2
square.y = stage.stageHeight / 2
}
}
}