11/06/2011

as3 非常常用的over out click(搭配TweenMax)


import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([BlurFilterPlugin]);
TweenPlugin.activate([TintPlugin, ColorTransformPlugin]);

//基本按鈕動作
mc.addEventListener(MouseEvent.ROLL_OVER,mc_ov)
mc.addEventListener(MouseEvent.ROLL_OUT,mc_ot)
mc.addEventListener(MouseEvent.CLICK,mc_clk)
mc.buttonMode = true

function mc_ov(e:MouseEvent):void {
//放大縮小
//TweenLite.to(e.currentTarget, 1, {scaleX:1.2, scaleY:1.2});
//彩度
//TweenMax.to(e.currentTarget, 1, {colorMatrixFilter:{brightness:1.7}});
}
function mc_ot(e:MouseEvent):void {
//TweenLite.to(e.currentTarget, 1, {scaleX:1, scaleY:1});
//TweenMax.to(e.currentTarget, 1, {colorMatrixFilter:{brightness:1}});
}
function mc_clk(e:MouseEvent):void {

}

//----搭配onComplete使用------------

import com.greensock.*;
import com.greensock.easing.*;

TweenMax.to(mc, 5, {delay:3, x:300, ease:Back.easeOut, onComplete:onFinishTween});

function onFinishTween():void {
trace("finish")
}
//----搭配onComplete使用------------


//---------物件動態-------------

import com.greensock.*;
import com.greensock.easing.*
;
//很像彈簧般的動態,前面振幅大
TweenLite.to(ball, 2, {y:0, ease:Elastic.easeOut});
//很像彈簧般的動態,前面振幅小
TweenLite.to(ball, 2, {y:0, ease:Elastic.easeIn});
//基本款移出
TweenLite.to(ball, 2, {y:0, ease:Quint.easeInOut});

//---------物件動態-------------

//---------.fromTo一次決定開始跟結束狀態-------------
TweenMax.fromTo(mc, 1, {x:600}, {x:300, tint:0xFF0000, onComplete:function(){trace("null")}});
//---------.fromTo一次決定開始跟結束狀態-------------






//--------多個按鈕使用同function,function又依照不同按鈕做不同事情--------


stop();

b1.addEventListener(MouseEvent.CLICK,mc_clk)
b1.buttonMode = true

b2.addEventListener(MouseEvent.CLICK,mc_clk)
b2.buttonMode = true

b3.addEventListener(MouseEvent.CLICK,mc_clk)
b3.buttonMode = true

b4.addEventListener(MouseEvent.CLICK,mc_clk)
b4.buttonMode = true

function mc_clk(e:MouseEvent):void {

if(e.currentTarget.name=="b1"){gotoAndStop(1)}
if(e.currentTarget.name=="b2"){gotoAndStop(2)}
if(e.currentTarget.name=="b3"){gotoAndStop(3)}
if(e.currentTarget.name=="b4"){gotoAndStop(4)}


}


//--------久久沒碰as3最實用文章,現學現賣--------
//--------多個按鈕使用同function,function又依照不同按鈕做不同事情--------





No comments:

Post a Comment