# [flash]用AS3實現Cover Flow效果 PART II – tweener改變色相&自訂EVENT

- URL: https://justfly.idv.tw/flash%e7%94%a8as3%e5%af%a6%e7%8f%becover-flow%e6%95%88%e6%9e%9c-part-ii-tweener%e6%94%b9%e8%ae%8a%e8%89%b2%e7%9b%b8%e8%87%aa%e8%a8%82event/
- 日期: 2009-06-23
- 分類: WEB&amp;RIA
- 標籤: actionscript, CoverFlow, event, flash, RIA, swf, Tweener

tweener的ColorShortcuts不只可以讓圖片的顏色動起來

也對以下的數值有作用:

- 彩度(saturation)[0~2]

- 色相(hue)[0~180]

- 對比(contrast)[0~3]

- 明度(brightness)[-1~1]

- 濃度(tinBrightness)[-1~1]

但是要動作前一樣要先初始ColorShortcuts

```
import caurina.transitions.properties.ColorShortcuts;
ColorShortcuts.init()
```

再來就一樣用Tweener的標準語法就可以歡樂控制了

```
Tweener.addTween(photo,{_saturation:val});
Tweener.addTween(photo,{_hue:val});
Tweener.addTween(photo,{_contrast:val});
Tweener.addTween(photo,{_brightness:val});
Tweener.addTween(photo,{_tinBrightness:val});
```

自訂EVENT比較麻煩點點

節錄一點比較相關的CODE:

justfly.GotoItemBtnEvent.as

```
package justfly{
	import flash.events.Event;
	public class GotoItemBtnEvent extends Event {
		public static const GotoItemBtn_Over:String="gotoItemBtnOver";
		public static const GotoItemBtn_Out:String="gotoItemBtnOut";
		public var percentage:Number=0;
		public function GotoItemBtnEvent(type:String) {
			super(type);
		}
	}
}
```

GotoItemBtn.as

```
private function gotoUrlBtnOver(e:MouseEvent):void{
this.dispatchEvent(new GotoItemBtnEvent(GotoItemBtnEvent.GotoItemBtn_Over));
}
private function gotoUrlBtnOut(e:MouseEvent):void{
this.dispatchEvent(new GotoItemBtnEvent(GotoItemBtnEvent.GotoItemBtn_Out));
}
```

Main.as

```
gotoItembtn.addEventListener(GotoItemBtnEvent.GotoItemBtn_Over,function(e:GotoItemBtnEvent){autoMoveTimer.stop();});
gotoItembtn.addEventListener(GotoItemBtnEvent.GotoItemBtn_Out,function(e:GotoItemBtnEvent){autoMoveTimer.start();});
```
