Flash/AS3 Classes

gpUrlLoader - Loading a JSON file

The following example displays the gpUrlLoader Class with an option to load a JSON file. Add the event listener, then call the init method with the url and the load type.

	var ldr:gpUrlLoader = new gpUrlLoader();
	ldr.addEventListener(Event.COMPLETE, jsonLoaded);
	ldr.addEventListener(ProgressEvent.PROGRESS, onProgress);
	ldr.addEventListener(gpUrlLoader.LOADERROR, ioError);
	ldr.init('my_json.js', 'json');

	function jsonLoaded(event:Event):void {
		var json:Object = ldr.getJson();
	}
	
	function onProgress(event:Event):void {
		trace(ldr.urlLoader.bytesLoaded);
	}
	
	function ioError(e:Event):void {
		trace('Error loading file');
	}	

For documentation about the gpUrlLoader AS3 Class, view the blog post.