如何在Adobe Flash CS3中更改Adobe Flash Player版本

时间:2013-11-03 00:08:59

标签: actionscript-3 flash actionscript cs3

我想创建一个Flash应用程序,通过用户的麦克风录制音频,然后上传到服务器,为此,我找到了这段代码:

import flash.media.Microphone;
import flash.events;

const DELAY_LENGTH:int = 4000;
var mic:Microphone = Microphone.getMicrophone(); 
mic.setSilenceLevel(0, DELAY_LENGTH); 
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler); 

function micSampleDataHandler(event:SampleDataEvent):void { 
  while(event.data.bytesAvailable) { 
    var sample:Number = event.data.readFloat(); 
    soundBytes.writeFloat(sample); 
  } 
}

我无法测试它,因为它会抛出这个编译错误:

"1046:Couldn't find type or is not a constant during compiling time: SampleDataEvent"

经过研究后我发现我必须更新Flash播放器版本以编译为10.0.0以使其正常工作,但我不知道该怎么做。我的IDE是Adobe Flash CS3 Portable,大部分示例都适用于Flex之类的其他IDE,我该怎么做?

1 个答案:

答案 0 :(得分:0)

您未导入flash.events.SampleDataEvent,并且soundBytes处理程序中未定义micSampleDataHandler

import flash.media.Microphone;
import flash.events.SampleDataEvent;
import flash.utils.ByteArray;

const DELAY_LENGTH:int = 4000;
var mic:Microphone = Microphone.getMicrophone(); 
mic.setSilenceLevel(0, DELAY_LENGTH); 
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler); 

function micSampleDataHandler(event:SampleDataEvent):void { 
  var soundBytes:ByteArray = new ByteArray();
  while(event.data.bytesAvailable) { 
    var sample:Number = event.data.readFloat(); 
    soundBytes.writeFloat(sample); 
  } 
}