flash on 2010-4-25

by kihon
♥0 | Line 28 | Modified 2010-04-25 11:04:37 | MIT License
play

ActionScript3 source code

/**
 * Copyright kihon ( http://wonderfl.net/user/kihon )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cali
 */

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.media.Sound;
	import flash.net.URLRequest;
	
	public class Main extends Sprite
	{
		public function Main()
		{
			var sound:Sound = new Sound(new URLRequest("http://www19.atpages.jp/aswiki/music.ttt"));
			sound.addEventListener(Event.COMPLETE, onComplete);
			sound.addEventListener(ProgressEvent.PROGRESS, onProgress);
		}

		private function onProgress(event:ProgressEvent):void 
		{
			trace(event.bytesLoaded);
			trace(event.bytesTotal);
		}

		private function onComplete(event:Event):void
		{
			var sound:Sound = event.currentTarget as Sound;
			sound.play(0, 10);
			trace(sound.length);
		}
	}
}