I am trying to add an event listener to my BitMap. Tile extends gameProps, which extends BitMap. I try using addEventListener. That doesnt work. but the Adobe docs say that Bitmap has an addEventListener object.
package {
import flash.display.BitmapData;
import flash.events.*;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.geom.Point;
public class Tile extends gameProps {
public var tileNum:Number = 0;
public function Tile(tileNumber:Number):void
{
tileNum = tileNumber;
addEventListener(MouseEvent.MOUSE_OVER, respond);
}
public function respond(e:MouseEvent):void
{ trace("HELLO");
}
}
}
The Bitmap class extends the DisplayObject not the InteractiveObject and can therefore not receive mouse events. Try wrapping the bitmap object in a Sprite sub-class. Something like this (pseudo-code):
public class Image extends Sprite
{
var bitmap:Bitmap;
public function Image()
{
bitmap = new Bitmap();
addChild( bitmap );
}
}
InteractiveObject Docs: http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/InteractiveObject.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With