Actionscript flash.display.Bitmap自身是否可以拥有事件?

Actionscript flash.display.Bitmap自身是否可以拥有事件?,actionscript,bitmap,Actionscript,Bitmap,这是可能的还是需要我做其他事情?问题是事件没有响应 [Embed(source="pic1.jpg")] private var Img1:Class; var i1:Bitmap = new Img1(); // not working i1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { t.htmlText = "Click!"; }); 如您所见

这是可能的还是需要我做其他事情?问题是事件没有响应

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

    var i1:Bitmap = new Img1();

   // not working 

    i1.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {
        t.htmlText = "Click!"; 
   }); 
如您所见,位图不是的后代。只有交互式对象才能成为Flash输入过程的一部分

要执行所需操作,请使用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!"; 
}); 

为什么不能在图像或精灵上设置宽度和高度?调整图像大小的最佳解决方案是什么?几年前,我用as3用flash做了一个imagegallery解决方案,一切都是movieclips。但现在我想在FlashBuilder中用纯as项目来做一个解决方案。雪碧和电影唇有很多不同之处。也许movieclips比Sprite有更多的功能?@marko您可以像其他任何东西一样设置Sprite的宽度和高度,最终结果就像您修改了scaleX和scaleY值一样。根据您的需要,使用宽度/高度或scaleX/scaleY(后者更不容易出现人为错误)。Sprite和MovieClip之间的唯一区别是后者可以有多个帧,这在AS-only环境中没有任何用处(除非您正在加载从flashprofessional导出的MCs)。如果不需要此功能,请使用Sprite。