-
Notifications
You must be signed in to change notification settings - Fork 11
/
waapisim.mxml
33 lines (30 loc) · 1.09 KB
/
waapisim.mxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="Start()" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0">
<mx:Script>
<![CDATA[
import flash.external.ExternalInterface;
import mx.controls.*;
public var WAAPISimSndch:SoundChannel;
public function Start():void {
setTimeout(InitializeWAAPISim,400);
setInterval(Interval,20);
}
public function InitializeWAAPISim():void {
var snd:Sound = new Sound();
snd.addEventListener(SampleDataEvent.SAMPLE_DATA, GetSamples);
WAAPISimSndch=snd.play();
}
private function Interval():void {
ExternalInterface.call("waapisimFlashOffset",WAAPISimSndch.position);
}
public function GetSamples(event:SampleDataEvent):void {
var dat:String = ExternalInterface.call("waapisimFlashGetData");
var l:uint=dat.length;
for(var i:int=0;i<l;++i) {
event.data.writeFloat((dat.charCodeAt(i)-32768)/16384);
}
}
]]>
</mx:Script>
<mx:Label id="lbl1" x="0" y="0" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0" text="WAAPISim.swf is loaded."/>
</mx:Application>