What error are you getting. My guess is that the addChild() is blowing up
because you're trying to add 'content' to the application when 'content' is
already a child of the loader. A displayobject can only be a child of one
displayobjectcontainer. Loaders are fairly low memory usage. I would just
add loader itself to the application and not worry about it. If you're
loading hundreds of images and you start to notice a problem, only then
would I would about optimizing memory management.
What are you trying to make. Based on what I see here, It's possible that
using a flex project as opposed to an Actionscript project will cut
development time significantly.
- Dan Freiman
On Dec 7, 2007 2:42 PM, lowerpower <[EMAIL PROTECTED]> wrote:
>
> 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();
> }
>
> }
> }
>
>
>