[AS3]Questions

I’m creating a class that will load external clips, hold them in a dictionary array by name. These clips are basically sprites, but contain 2-4 different “rotations”. This sprite loader will receive requests for sprites, and it will return BitmapData.

Now the questions


 package dazzer.engine
 {
   import flash.utils.Dictionary
   import flash.display.Loader
   import flash.net.*

    public class spriteLoader
    {
         private var myClips:Dictionary();
          public function spriteLoader():void
         {
               myClips = new Dictionary();
         }
         function loadPath(name:String, path:String):void
         {
               //This part is truncated to save time
               temp:Loader = new Loader()
               temp.load(new URLRequest(path));
               myClips[name] = temp.content
         }
    }
 }
 
  1. Does my class need to extend anything? Or can i just create it like that? Since it doesn’t have to be in the displaylist.

  2. I know the code above won’t work. But its just the general idea.
    What steps should i take for Garbage Collection? If , say, I wish to clear all the memory on the sprites, should i just put

myClips = new Dictionary();

what if i wanted to remove just 1 sprite from memory? I don’t have a reference to the Loader anymore? Would

myClips["whatever"] = null

qualify that Loader it was referencing for collection?

Thank you anyone for their reply