Reputation: 7
I have this code to simply load an image and display it in flash as3.
function mem(evt:*=null){
trace(Number( System.totalMemory / 1024 / 1024 ).toFixed( 3 ) + 'Mb')
}
mem();
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onloaded)
loader.load(new URLRequest("../capture.jpg"))
addChild(loader);
function onloaded(e:Event):void {
mem();
}
The capture.jpg has 234KB.
The problem is that after loading the System.totalMmemory increase his size with more than 1Mb
Traces: before and after loading
17.391Mb
18.746Mb
Seems like flash load, decompress and store the image as raw data.
Is there a way to keep the image at his original size after loading? Thank you!
Upvotes: 0
Views: 235
Reputation: 10817
No, there is no way to keep the image in it's original size. Flash, or any other graphic environment has to decode the image to raw data to show it.
The only way to solve your problem is to free the memory once you don't need the image anymore, and only load the images you need to show.
Upvotes: 4
Reputation: 2168
I might be right or wrong about this, but here's how I understand it: jpg is a compressed format and when the load is complete, Flash, or for that matter, any web page, has to uncompress the jpg in memory. A gif on the other hand, has no compression, so it may be a larger initial size sometimes, but no decompression takes place. Try loading the asset as a gif (may not be ideal for continuous tone images) and see if your trace outputs remain the same.
Upvotes: 0