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

问题描述 投票:0回答:1

我想创建一个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,大部分示例都适用于其他IDE,如Flex,我该怎么做?

actionscript-3 flash actionscript cs3
1个回答
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); 
  } 
}
© www.soinside.com 2019 - 2024. All rights reserved.