PageRenderTime 222ms CodeModel.GetById 120ms app.highlight 4ms RepoModel.GetById 97ms app.codeStats 0ms

/flash/MP3FileReferenceLoaderLib/demo/MP3FileReferenceTest.as

http://echo-nest-remix.googlecode.com/
ActionScript | 36 lines | 34 code | 2 blank | 0 comment | 0 complexity | 128827e783a6fb1e83c7613e1991de6d MD5 | raw file
 1package {
 2	import flash.display.Sprite;
 3	import flash.events.Event;
 4	import flash.events.MouseEvent;
 5	import flash.net.FileFilter;
 6	import flash.net.FileReference;
 7	
 8	import org.audiofx.mp3.MP3FileReferenceLoader;
 9	import org.audiofx.mp3.MP3SoundEvent;
10
11	public class MP3FileReferenceTest extends Sprite
12	{
13		private var loader:MP3FileReferenceLoader;
14		private var fileReference:FileReference;
15		public function MP3FileReferenceTest()
16		{
17			loader=new MP3FileReferenceLoader();
18			loader.addEventListener(MP3SoundEvent.COMPLETE,mp3LoaderCompleteHandler);
19			fileReference=new FileReference();
20			fileReference.addEventListener(Event.SELECT,fileReferenceSelectHandler);
21			stage.addEventListener(MouseEvent.CLICK,clickHandler);
22		}
23		private function clickHandler(ev:MouseEvent):void
24		{
25			fileReference.browse([new FileFilter("mp3 files","*.mp3")]);
26		}
27		private function fileReferenceSelectHandler(ev:Event):void
28		{
29			loader.getSound(fileReference);
30		}
31		private function mp3LoaderCompleteHandler(ev:MP3SoundEvent):void
32		{
33			ev.sound.play();
34		}
35	}
36}