Dear all,
I would like to make the following code to a CLASS
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
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:
var c:ABC = new ABC();
It can output “OK”
but the image can’t be loaded on screen ??
Any body can help ??
Thanks ~~