actionscript 3 - AS3 - Can Bitmap classes dispatch mouse events? -
i'm trying learn as3 , have run small problem.
i have bitmap class add mouseevent.click
listener, event doesn't seem dispatched.
i use flashdevelop write as3 code , flex compile.
i have 2 classes, enemy.as
, player.as
the player.as
looks this:
package player { import flash.display.sprite; import flash.events.mouseevent; [embed(source="../../assets/leek.swf", symbol="leek")] public class player extends sprite { public function player() { trace("player constructed"); addeventlistener(mouseevent.click, handleclick); } private function handleclick(e:mouseevent):void { trace("clicked player"); } } }
the enemy.as
looks this:
package enemies { import flash.display.bitmap; import flash.events.mouseevent [embed(source="../../assets/gardengnome.png")] public class enemy extends bitmap { public function enemy() { trace("enemy constructed"); addeventlistener(mouseevent.click, handleclick); } private function handleclick(e:mouseevent):void { trace("clicked enemy"); } } }
the 2 classes pretty identical except 1 sprite
, embedded symbol swf
file got tutorial, , other bitmap
, embedd png
file that.
the player
class (the 1 that's sprite , uses symbol) fires off mouseevent.click
when run project , click on player image, enemy
class not.
there no compile warnings or errors, i'm having hard time understanding issue exactly. because 1 sprite
, other bitmap
, or because 1 uses prepared symbol swf
, while other png
?
how can make bitmap
class respond mouseevent
?
thanks help!
from actionscript® 3.0 reference adobe® flash® platform:
the bitmap class not subclass of interactiveobject class, cannot dispatch mouse events. however, can use addeventlistener() method of display object container contains bitmap object.
Comments
Post a Comment