Thnx for the links... tried some, but still with no success... I now have the 
following:

public class Image extends MovieClip
{
 private var _thumbLoader:Loader;
 private var _largeLoader:Loader;
 
 private var _thumb:Bitmap;
 private var _large:Bitmap;
 
 public function loadThumb() :void
 {
  _thumbLoader = new Loader();
  _thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
                                        thumbLoaded, false, 0, true);
  _thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
                                        errorOccured, false, 0, true); 
  _thumbLoader.load(new URLRequest(_tu)); 
 }
                
 private function thumbLoaded( e :Event ) :void 
 {
  _thumb = Bitmap(e.currentTarget.content);
  _thumb.smoothing = true;
                        
  addChild(_thumb);
                        
  _thumbLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, 
                                                                thumbLoaded);
  _thumbLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, 
                                                                errorOccured);
  _thumbLoader = null;
                        
  dispatchEvent(new Event(Image.IMG_LOADED));
 }

 public function loadLarge() :void
 {
  _largeLoader = new Loader();
  _largeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
                                        largeLoaded, false, 0, true);
  _largeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
                                        errorOccured, false, 0, true); 
  _largeLoader.load(new URLRequest(_lu));
 }
                
 private function largeLoaded( e :Event ) :void 
 {
  _large = e.currentTarget.content;
  _large.smoothing = true;
  addChild(_large);
                        
  _largeLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, 
                                                                largeLoaded);
  _largeLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, 
                                                                errorOccured);
  //_largeLoader.content.dispose();
  _largeLoader = null;
                        
  dispatchEvent(new Event(Image.IMG_LOADED));
 }
 public function disposeLarge() :void
 {
  if (_large)
   {
    removeChild(_large);
    _large.bitmapData.dispose();
    _large = null;
   }
 }

public function dispose() :void
 {
  disposeLarge();  

  removeChild(_thumb);
  _thumb.bitmapData.dispose();
  _thumb = null
 }

}

Anyone some tips? The large bitmap stays in memory...

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike
Sent: Wednesday, 21 January 2009 21:18
To: Flash Coders List
Subject: Re: [Flashcoders] Garbage Collection difficulty

Hi,

    I think if you use it locally, you still have to "dispose" of it:

    http://www.bartclaessens.com/tag/memory-management/

    http://labs.bigspaceship.com/2007/02/28/flash-performance-tips-part-ii/

    http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html

    Search for "dispose" in some of these - also, one of the comments in 
Grant's article mentions testing in the IDE vs testing in the browser 
gives different results for loaded images.

    HTH

    Glen

Sander Schuurman wrote:
> That's a local variable right? Doesn't it happen automatic?
> I must concentrate on the _large Sprite, isn't it?
>
>
> -----Original Message-----
> From: flashcoders-boun...@chattyfig.figleaf.com 
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike
> Sent: Wednesday, 21 January 2009 12:20
> To: Flash Coders List
> Subject: Re: [Flashcoders] Garbage Collection difficulty
>
> Hi,
>       
>     Do you have to destroy the Bitmap you create in the largeLoaded 
> function???
>
>     Glen
>
> Sander Schuurman wrote:
>   
>> Hi cool list,
>>
>> I'm struggling with my Image class. It's supposed to load and unload 
>> different sized images dynamicly; but I can't seem to get it to work 
>> properly. The loading works fine, but the unloading not for the full 100%. 
>> It visually unloads the image, but it remains in the memory. I have tried 
>> several different things; I'm a bit stuck now.
>>
>> Here is a stripped class:
>>
>> public class Image extends MovieClip
>> {
>> ...
>>             private var _largeLoader:Loader;
>> private var _large:Sprite;
>> ...
>> public function Image(     thumbUrl           :String,
>>                                                 normalUrl          :String,
>>                                                 largeUrl :String   )
>> {
>>                         _tu = thumbUrl;
>>                         _nu = normalUrl;
>>                         _lu = largeUrl;
>> }
>> ...
>> public function loadLarge() :void
>> {
>>                         _largeLoader = new Loader();
>>                         
>> _largeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, largeLoaded, 
>> false, 0, true);
>>                         
>> _largeLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
>> errorOccured, false, 0, true);
>>                         _largeLoader.load(new URLRequest(_lu));
>> }
>>
>> private function largeLoaded( e :Event ) :void
>> {
>>                         var b:Bitmap = Bitmap(largeLoader.content);
>>
>>                         
>> _largeLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, 
>> largeLoaded);
>>                         
>> _largeLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, 
>> errorOccured);
>>                         _largeLoader = null;
>>
>>                         _large = new Sprite();
>>                         _large.addChild(b);
>>                         addChild(_large);
>>
>>                         dispatchEvent(new Event(Image.IMG_LOADED));
>> }
>> ...
>>             public function clear( full :Boolean = false ) :void
>>             {
>>                         // clear normal img and large img
>>                         ... ?
>>
>>                         // tried things like:
>>
>>                         //_normal.removeChildAt(0);
>>                         //_normal = null;
>>                         //removeChild(_normal);
>>                         //_large.removeChildAt(0);
>>                         //_large             = null;
>>                         //removeChild(_large);
>>                         //delete(_normal.removeChildAt(0));
>>                         //delete(_large.removeChildAt(0));
>>
>>                         // removes the images visually, but they won't get 
>> GC'ed
>>
>> if (full)
>> {
>>             // clear thumb and itself
>> }
>>             }
>> }
>>
>> Thanks in advance!
>> _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>
>>   
>>     
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
>   

-- 

Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to