How do you load a bitmap file into a BitmapData object?

后端 未结 5 1756
遥遥无期
遥遥无期 2020-12-15 21:41

In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method.

How do you load an ex

5条回答
  •  佛祖请我去吃肉
    2020-12-15 21:47

    AS3 code to load a PNG and "get" its bitmapData

    var bitmapData:BitmapData;
    
    var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
        loader.load(new URLRequest("../lib/img.png"));
    
    function onComplete (event:Event):void
    {
        bitmapData = Bitmap(LoaderInfo(event.target).content).bitmapData;
    }
    

提交回复
热议问题