2011-08-05 40 views

回答

2

影片剪辑有一个属性mouseChildren,这意味着每个事件只发送到这个容器,而不是它的子元素:myMovieClip.mouseChildren = false;

2
package 
{ 
    import flash.display.Sprite; 
    import com.*; 
    import flash.text.TextField; 
    import flash.events.MouseEvent; 

    public class Chk extends Sprite 
    { 
     private var ba:Ball; 
     private var txt:TextField; 
     public function Chk():void 
     { 
      ba= new Ball(50, 0xf0fff00, 1); 
      txt = new TextField(); 
      txt.text = "HI"; 
      ba.addChild(txt); 
      addChild(ba); 
      ba.buttonMode = true; 
      ba.mouseChildren = false; 
      ba.x = stage.stageWidth/2; 
      ba.y = stage.stageWidth/2; 
      ba.addEventListener(MouseEvent.CLICK, action); 
     } 
     private function action(e:MouseEvent):void 
     { 
      trace("clicked"); 
     } 
    } 
} 

.......