# [AS3]mouseEnabled:移動標籤

- URL: https://justfly.idv.tw/as3mouseenabled%e7%a7%bb%e5%8b%95%e6%a8%99%e7%b1%a4/
- 日期: 2009-10-08
- 分類: WEB&amp;RIA
- 標籤: actionscript, RIA

這應該是一個關於movieClip的感應區的問題

在AS3中要多設一個mouseEnabled的屬性

對動態文字跟movieClip都有效

[沒有設定mouseEnabled]

[設定mouseEnabled後]

完整程式碼:

```
package {

	import flash.display.*;
	import flash.events.*;
	import flash.utils.Timer;

	import caurina.transitions.Tweener;
	import caurina.transitions.properties.ColorShortcuts;
	ColorShortcuts.init();

	public class Main extends Sprite {
		var textTxt:TextMc = new TextMc();
		var biruArr:Array=new Array("","ビル1","ビル2","ビル3");

		public function Main() {
			btn_biru1.buttonMode=true;
			btn_biru1.addEventListener(MouseEvent.MOUSE_OVER,biru_over);
			btn_biru1.addEventListener(MouseEvent.MOUSE_OUT,biru_out);

			btn_biru2.buttonMode=true;
			btn_biru2.addEventListener(MouseEvent.MOUSE_OVER,biru_over);
			btn_biru2.addEventListener(MouseEvent.MOUSE_OUT,biru_out);

			btn_biru3.buttonMode=true;
			btn_biru3.addEventListener(MouseEvent.MOUSE_OVER,biru_over);
			btn_biru3.addEventListener(MouseEvent.MOUSE_OUT,biru_out);
			
			Tweener.addTween(btn_biru1,{_brightness:-1})
			Tweener.addTween(btn_biru2,{_brightness:-1})
			Tweener.addTween(btn_biru3,{_brightness:-1})

			stage.addEventListener(MouseEvent.MOUSE_MOVE,textMove);
			textTxt.alpha=0;
			textTxt.mouseEnabled=false;
			textTxt.main_txt.mouseEnabled=false;
			this.addChild(textTxt);
		}

		private function biru_over(e:MouseEvent) {
			e.target.gotoAndStop("over");
			textTxt.main_txt.text=biruArr[e.target.name.charAt(8)];
			Tweener.addTween(textTxt, {alpha:1 , time:0.5});
			Tweener.addTween(e.target,{_brightness:-0.5,time:1,transition:"easeOutBack"})
		}
		private function biru_out(e:MouseEvent) {
			e.target.gotoAndStop("out");
			Tweener.addTween(e.target,{_brightness:-1,time:1,transition:"easeOutBack"})
			Tweener.addTween(textTxt, {alpha:0 , time:0.5});
		}
		private function textMove(e:MouseEvent) {
			Tweener.addTween(textTxt, {x:mouseX,y:mouseY , time:0.8 , transition:"easeOutQuint"});
		}
	}
}
```
