views:

24

answers:

1

i've used a Loader and URLRequest to download a .png from the internet and add it to my display list. since it's already a bitmap, does it have built in bitmap data already? or do i have to create the bitmap data myself?

also, why does the same trace statement return false in the mouseMoveHandler when it outputs true in the displayImage function?

    var imageLoader:Loader = new Loader();
    imageLoader.load(new URLRequest("http://somewebsite.com/image.png"));
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, displayImage);

    function displayImage(evt:Event):void
     {
     addChild(evt.target.content);
     addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

     trace(evt.target.content is Bitmap);  //outputs 'true'
     }

   function mouseMoveHandler(evt:MouseEvent):void
     {
     trace(evt.target.content is Bitmap);  //outputs 'false'
     }
+1  A: 

A quick search of the AS3 docs tells me that Bitmap has a bitmapData property.

You are getting different rusults in each trace because you are tracing different things. try just tracing the property rather that "is Bitmap", to see what is actually stored there.

Your first trace you are tracing an Event, your second a MouseEvent. Your displayImage function is a "Loader Complete handler", so target will be a LoaderInfo object. In a LoaderInfo object, target refers to "The loaded DisplayObject associated with this LoaderInfo object". But in a MouseEvent the target will be different. You will need to refer to the docs for each event to find out what the target will be.

Also, I think you will need to add the mouse move event listener to the stage, or it wont work e.g.

stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
TandemAdam
ouf. that was a really dumb question. i blame the heat. ;)
TheDarkInI1978