loading image by Loader.loadBytes(byteArray)

后端 未结 1 1202
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 03:05

i like to ask about one thing :

If i create Loader and load external image by URLRequest , ill have result :

loader.content is Bitmap
loader.content.bitm         


        
相关标签:
1条回答
  • 2021-01-29 03:42

    AS3 Loader has internal parsing to try and match datatypes to internal class types. It's pretty handy in most cases, but the syntax is a little weird.

    In your example above, you CAN cast the bytesLoader.content as Bitmap if you'd rather.

    Edit (in reference to the "how" question):

    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, getImage);
    
    ldr.load ( new URLRequest ( IMAGE_URL ) );
    
    function getImage (e:Event):void {
        var bmp:Bitmap = ldr.content as Bitmap;
        addChild (bmp);
    }
    

    You should be able to simply cast it as a Bitmap.

    0 讨论(0)
提交回复
热议问题