2/13/2011
as3 "for"+"array"+"Interval"+"tweenr"物件輪播
/*by keitaro2008*/
import caurina.transitions.Tweener;
//var product_ratio:Array = [200, 150, 100, 50,];//用陣列敘述大小用不到
var positions:Array = [[100, 100], [200, 100], [300, 100], ];
var products:Array = [p00,p01,p02];
var uu:int = 1;//uu=time
//btn_stop只是停止按鈕
btn_stop.addEventListener(MouseEvent.CLICK, stop_it);
function stop_it(event:MouseEvent){
clearInterval(test);//清除Interval
gotoAndStop(1);;
trace("stop");
}
for (var i:int = 0; i <= 2; i++)//用for+array定位置
{
products[i].x=positions[i][0];
products[i].y=positions[i][1];
}
function motion(){
trace("motion執行中");
Tweener.addTween(products[0], {
x:positions[2][0],
y:positions[2][1],
alpha: 1,
time: 1*uu,
delay:0*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[1], {
x:positions[0][0],
y:positions[0][1],
alpha: 1,
time: 1*uu,
delay:0*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[2], {
x:positions[1][0],
y:positions[1][1],
alpha: 1,
time: 1*uu,
delay:0*uu,
transition: "easeOutExpo"
});
//_________________________________________________
Tweener.addTween(products[0], {
x:positions[1][0],
y:positions[1][1],
alpha: 1,
time: 1*uu,
delay:1*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[1], {
x:positions[2][0],
y:positions[2][1],
alpha: 1,
time: 1*uu,
delay:1*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[2], {
x:positions[0][0],
y:positions[0][1],
alpha: 1,
time: 1*uu,
delay:1*uu,
transition: "easeOutExpo"
});
//_________________________________________________
Tweener.addTween(products[0], {
x:positions[0][0],
y:positions[0][1],
alpha: 1, //
time: 1*uu,
delay:2*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[1], {
x:positions[1][0],
y:positions[1][1],
alpha: 1,
time: 1*uu,
delay:2*uu,
transition: "easeOutExpo"
});
Tweener.addTween(products[2], {
x:positions[2][0],
y:positions[2][1],
alpha: 1,
time: 1*uu,
delay:2*uu,
transition: "easeOutExpo"
});
}
motion()//執行motion函式
var test = setInterval(showMessage,uu*3000);
//setInterval控制輪播、uu*3000為時間
function showMessage(){
trace("一輪");
motion();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment