URLLoader Event.COMPLETE is not working

hi all,

as first, i want to say that i’m using Haxe that is a kind of emulator of AS

I’m having some issues with the listener Event.COMPLETE for the urlloader.
It’s like the trigger is not working and the function is not called, i even tried to call different listener but none of them is working.
Here’s my code:


var urlLoader : URLLoader;

public function new(apiURL) {
	super();
	this.urlLoader = new URLLoader();
	// json loader
	load_json(apiURL);
}

public function load_json(apiURL){
	this.urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
	this.urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
	this.urlLoader.addEventListener(ProgressEvent.PROGRESS, onProgress);
	this.urlLoader.addEventListener(Event.COMPLETE, onComplete);
	this.urlLoader.load(new URLRequest(apiURL + "?cachebust=" + Math.floor(100000+900000*Math.random()))); // for cache...
}
    
private function onComplete(e:Event) {throw "complete";}
private function onProgress(e:ProgressEvent) {throw "progree";}
private function onSecurityError(e:SecurityErrorEvent) {throw "error";}
private function onIOError(e:IOErrorEvent) {throw "io error";}


now, apiURL is surely filled and the url is parsed but none of those trigger is called,
hope you can help because i’m going crazy!

Thanks!

Does “new” actually work for a function name? (I guess so with haxe, or maybe it represents the constructor… I guess that makes more sense. Been a while since I looked into haxe)

Are you testing this in a browser? Have you looked at networking in the console to see the progress of this file as its downloaded?