# Preloader - When should I use one, how and why?

**URL:** <https://forum.kirupa.com/t/preloader-when-should-i-use-one-how-and-why/301016>\
**Category:** programming\
**Created:** [December 2, 2009, 2:35pm UTC](https://forum.kirupa.com/t/preloader-when-should-i-use-one-how-and-why/301016 "2009-12-02T14:35:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sluimers\_](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sluimers\_](https://forum.kirupa.com/u/sluimers_)\
**Post date:** [December 2, 2009, 2:35pm UTC](https://forum.kirupa.com/t/preloader-when-should-i-use-one-how-and-why/301016/1 "2009-12-02T14:35:16Z")

</div>

I think I might need a preloader as I load in tilesets. My problem is that I have no idea how to do this. The examples I have seen so far preload swf files.  
I don’t think that that is what I need as I don’t see how that preloads all png files that my game uses, for example this class:

```auto

package nl.obg.www {
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.net.URLRequest;
    
    public class Flag extends Sprite {
        private var tileSize:uint;
        
        public var tx:int;
        public var ty:int;
        
        private var _loader:Loader;
        
        public function Flag(nwX:int, nwY:int, nwZ:int){
            x = nwX;
            y = nwY;
            z = nwZ;
            
            _loader = new Loader();
            addChild(_loader);
            _loader.load(new URLRequest("../images/flag.png"));
        }
        
        public function init():void {
            tileSize = (parent as Map).getTileSize();
            
            tx = x;
            ty = y;
            
            x = x*tileSize;
            y = y*tileSize;
        }
    }
}

```

How would one preload this png and others?
