PDA

View Full Version : embed as displayobject


daemonk
02-16-2009, 08:07 AM
I am using flash cs4. I embed a .png image using:

[Embed (source="/myImage.png" )]
public static const myImage:Class;

Then I instantiated it as a DisplayObject

var imageObj : DisplayObject = new myImage();

I compiled it and everything worked. The image showed up.

I went back and tried to add a mouse event to the imageObj by:

imageObj.addEventListener(MouseEvent.MOUSE_MOVE, myfunction)

I ran it, no errors while compiling. But it doesn't register any mouse events. I tried click, mouse over...etc and none worked. Am I doing something wrong? Am I not supposed to cast an embed image as a displayobject?