How to set a bitmap as a button so that i can apply button mode and mouse-event stuff on it, without adding the bitmap to a Movie Clip?
var bmpFull=new Bitmap(event.currentTarget.content.bitmapData);
Unfortunately, Bitmap objects do not extend from the InteractiveObject class - that is, they don't have (and cannot easily get) the ability to receive mouse events.
As pointed out by antpaw and Jeremy White in the previous answer, the simplest container class that does receive mouse events is the Sprite class. Therefore, if you wanted to have a Bitmap receive mouse events, and not use a MovieClip, you could use a Sprite:
var bmpFull:Bitmap = new Bitmap(event.currentTarget.content.bitmapData); bmpFull.smoothing = true; bmpFull.name = "photo"; bmpFull.alpha = 0; var bmpContainer:Sprite = new Sprite(); // can receive mouse events, for example: bmpContainer.addEventListener(MouseEvent.CLICK, clickHandler); bmpContainer.buttonMode = true; // this just makes it show the hand cursor, and is not necessary for the mouse events to work bmpContainer.addChild(bmpFull);
In fact, I would recommend using a Sprite, as they're simpler objects than MovieClips and thus do not require as much memory.
Now, if you wanted to make a Bitmap dispatch mouse events without using any sort of container clip, you'd probably need to write your own extension of the Bitmap class that had it's own event manager. That would be far, far more complicated. I highly recommend just using a Sprite as a container.
buttonMode is a property of Sprite
inheritance of a movie clip goes like this
MovieClip >> Sprite >> DisplayObjectContainer >> InteractiveObject >> DisplayObject >> EventDispatcher >> Object Bitmap >> DisplayObject >> EventDispatcher >> Object