2010年12月27日 星期一

Tweener●_bezier - 延著貝茲曲線路徑移動




import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;

CurveModifiers.init();

//
var _mc:MovieClip = new MovieClip();
with (_mc.graphics)
{
 beginFill(0xddaa00, 1);
 drawCircle(20,20,36);
 endFill();
}
addChild(_mc);

//
tween_1();
//
function tween_1():void
{
 Tweener.addTween(_mc,
 {
 x:480,
 y:100, 
 _bezier:{x:250, y:600},
 delay:0.5,
 time:1.5,
 scaleX:1.5,
 scaleY:1.5,
 transition:"easeInOutQuint",
 onComplete:tween_2
 }
 );
}

//
function tween_2():void
{
 Tweener.addTween(_mc,
 {
 x:30,
 y:30, 
 _bezier:{x:300, y:400},
 delay:0.5,
 time:3,
 scaleX:1,
 scaleY:1,
 transition:"easeInOutQuint",
 onComplete:tween_1
 }
 );
}

addChild(click_mc);
click_mc.buttonMode = true;
click_mc.flag = true;
click_mc.addEventListener(MouseEvent.CLICK, removeBall);
function removeBall(e:MouseEvent):void{
 if(click_mc.flag){
  removeChild(_mc);
  click_mc.flag = false;
 }else{
  addChild(_mc);
  click_mc.flag = true;
 }
 
}

沒有留言: