# \[Q\] Loader not work in Class?

**URL:** <https://forum.kirupa.com/t/q-loader-not-work-in-class/237112>\
**Category:** Uncategorized\
**Created:** [August 27, 2007, 1:24pm UTC](https://forum.kirupa.com/t/q-loader-not-work-in-class/237112 "2007-08-27T13:24:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfree](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@manfree](https://forum.kirupa.com/u/manfree)\
**Post date:** [August 27, 2007, 1:24pm UTC](https://forum.kirupa.com/t/q-loader-not-work-in-class/237112/1 "2007-08-27T13:24:18Z")

</div>

Dear all,  
I would like to make the following code to a CLASS

```auto
 
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest("http://localhost/1.png"));
function onLoaded(e:Event):void {
 addChild(loader);
}

```

The above code works fine,  
then i make it to CLASS

```auto
 
package {
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.display.Loader;
 import flash.net.URLRequest;
 
 public class ABC extends Sprite {
  private var loader:Loader;
 
  public function ABC() {
   this.loader = new Loader();
   this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
   this.loader.load(new URLRequest("http://localhost/1.png"));
  }
  function onLoaded(e:Event):void {
   addChild(this.loader);
   trace("OK");
  }
 }
}

```

In the FLA file:

```auto
 
var c:ABC = new ABC();

```

It can output “OK”  
but the image can’t be loaded on screen ??  
Any body can help ??

Thanks ~~
