开发者

Can flash.display.Bitmap have events on themself?

开发者 https://www.devze.com 2023-02-17 14:41 出处:网络
Is this possible or need I do it anyway else? The problem is that the event is not responding. [Embed(source=\"pic1.jpg\")]

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

精彩评论

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