Flex actionscript code for activitylevel

梦想的初衷 提交于 2020-01-17 06:59:35

问题


Can any one indicata me a small piece of code for making this progress bar move on mic activitylevel. i.e, When spoken on the microphone the progressbar should indicate it.Also which works on internet explorer

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application
 xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute"
 width="300"
 height="100"
creationComplete="init()">

<mx:Script>
<![CDATA[
 import mx.controls.Alert;
 import flash.net.NetStream;

 private var myMic:Microphone;
 private var recordingState:String = "idle";

 private function init():void {

    myMic = Microphone.getMicrophone();
    myMic.setSilenceLevel(0);
    myMic.rate = 44;
    myMic.gain = 100;

    micLevel.visible = true;
    Security.showSettings(SecurityPanel.MICROPHONE);
    myMic.setLoopBack(true);
    if (myMic != null)
    {
       myMic.setUseEchoSuppression(true);
       micLevel.setProgress(myMic.activityLevel, 100);
       addEventListener(Event.ENTER_FRAME, showMicLevel);
       //micLevel.setProgress(myMic.activityLevel, 100);
    }

 }



]]>
 </mx:Script>

<mx:ProgressBar x="0" y="36" mode="manual" id="micLevel" label="" labelPlacement="bottom" width="100" fontSize="10" fontWeight="normal"/>

</mx:Application>

回答1:


You need to add a callback function for the event. You have it defined as showMicLevel but you have no implementation of that function.

   private function showMicLevel(e: Event):void{
      micLevel.setProgress(myMic.activityLevel, 100);
   }


来源:https://stackoverflow.com/questions/4585656/flex-actionscript-code-for-activitylevel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!