开发者

Can flash.display.Bitmap have events on themself?

Is this possible or need I do it anyway else? The problem is that the event is not responding.

  [Embed(source="pic1.jpg")]
  开发者_如何学C  private var Img1:Class; 

    var i1:Bitmap = new Img1();

   // not working 

    i1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
        t.htmlText = "Click!"; 
   }); 


As you can see Here, Bitmap is not descendant of InteractiveObject. Only interactive objects can be part of an input processes of Flash.

To do what you want encapsulate the Bitmap with Sprite:

[Embed(source="pic1.jpg")]
private var Img1:Class; 

var i1:Bitmap = new Img1();
var s1:Sprite = new Sprite();

s1.addChild(i1);    

s1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
    t.htmlText = "Click!"; 
}); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜