I've been trying to figure this out, but actionscript is new to me.
I want the code to not blow up memory too, so the old image after done
with use should be freed. This is one of my attempts but it only
displays one image and memory gets out of control:
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.System;
public class Application extends Sprite{
private var currentLdr:Loader;
private var request:URLRequest;
private var i:int;
function Application(){
i=0;
//this.request = new URLRequest("http://10.10.11.105/usr/yoics3.jpg");
this.loadNextImage();
}
private function loadNextImage(){
this.currentLdr = new Loader();
this.currentLdr.contentLoaderInfo.addEventListener(Event.COMPLETE,
this.loadCompleteHandler,false,0,true);
this.currentLdr.contentLoaderInfo.addEventListener(Event.UNLOAD,
this.unloadCompleteHandler,false,0,true);
this.request = new URLRequest("http://10.10.11.105/usr/yoics3.jpg?"+i);
this.currentLdr.load(this.request);
trace("Current mem: " + System.totalMemory);
}
private function loadCompleteHandler(event:Event):void
{
// Display first
this.addChild(this.currentLdr.content);
this.currentLdr.unload();
}
private function unloadCompleteHandler(event:Event):void
{
this.loadNextImage();
}
}
}