Flash/AS3 Classes

gpUrlLoader - Load Sound

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

I also added a progress and Load Error Listener. With the Progress Listener, you can track bytesLoaded and bytesTotal.

	var ldr:gpUrlLoader = new gpUrlLoader();
	ldr.addEventListener(Event.COMPLETE, soundLoaded);
	ldr.addEventListener(ProgressEvent.PROGRESS, onProgress);
	ldr.addEventListener(gpUrlLoader.LOADERROR, ioError);
	ldr.init('StarGate-SG1-mp3', 'sound');

	function soundLoaded(event:Event):void {
		var snd:Sound = ldr.getSound();
	}
	
	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.