2014-01-21 43 views
1

我想用flash播放器,以節省我的錄製音頻,通過JavaScript 通過文件名我已經想盡各種辦法像How to pass Object tag PARAM value into Flash? & How to read the param value from the object tag using javascript傳遞的文件名,但他們都沒有爲我工作如何通過閃存保存錄制的音頻,通過JavaScript鉻

我有一個JavaScript嵌入.swf其中AudioRecorder.swf是我的閃存記錄器和recordingFileName動態分配。 (參考:http://code.google.com/p/swfobject/wiki/documentation

swfobject.embedSWF("AudioRecorder.swf", "myAlternativeContent", "350px", "350px", "9.0.0", "expressInstall.swf", recordedFileName, "fileName", "");

HTML代碼:

<div id="myAlternativeContent"> 
    <a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash Players</a> 
</div> 

的AudioRecorder.swf代碼:(參考:http://dev.tutsplus.com/tutorials/create-a-useful-audio-recorder-app-in-actionscript-3--active-5836

public class Main extends Sprite 
{ 
    private var mic:Microphone; 
    private var waveEncoder:WaveEncoder = new WaveEncoder(); 
    private var recorder:MicRecorder = new MicRecorder(waveEncoder); 
    private var recBar:RecBar = new RecBar(); 
    private var tween:Tween; 
    private var fileReference:FileReference = new FileReference(); 


    public var recordedFileName:String; 

    public function Main():void 
    { 
     recordedFileName = this.loaderInfo.parameters.fileName; 

     trace(recordedFileName); 
     recButton.stop(); 
     activity.stop(); 

     mic = Microphone.getMicrophone(); 
     mic.setSilenceLevel(0); 
     mic.gain = 100; 
     mic.setLoopBack(true); 
     mic.setUseEchoSuppression(true); 
     Security.showSettings("2"); 

     addListeners(); 
    } 

    private function addListeners():void 
    { 
     recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording); 
     recorder.addEventListener(RecordingEvent.RECORDING, recording); 
     recorder.addEventListener(Event.COMPLETE, recordComplete); 
     activity.addEventListener(Event.ENTER_FRAME, updateMeter); 
    } 

    private function startRecording(e:MouseEvent):void 
    { 
     if (mic != null) 
     { 
      recorder.record(); 
      e.target.gotoAndStop(2); 

      recButton.removeEventListener(MouseEvent.MOUSE_UP, startRecording); 
      recButton.addEventListener(MouseEvent.MOUSE_UP, stopRecording); 

      addChild(recBar); 

      tween = new Tween(recBar,"y",Strong.easeOut, - recBar.height,0,1,true); 
     } 
    } 

    private function stopRecording(e:MouseEvent):void 
    { 
     recorder.stop(); 

     mic.setLoopBack(false); 
     e.target.gotoAndStop(1); 

     recButton.removeEventListener(MouseEvent.MOUSE_UP, stopRecording); 
     recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording); 

     tween = new Tween(recBar,"y",Strong.easeOut,0, - recBar.height,1,true); 
    } 

    private function updateMeter(e:Event):void 
    { 
     activity.gotoAndPlay(100 - mic.activityLevel); 
    } 

    private function recording(e:RecordingEvent):void 
    { 
     var currentTime:int = Math.floor(e.time/1000); 

     recBar.counter.text = String(currentTime); 

     if (String(currentTime).length == 1) 
     { 
      recBar.counter.text = "00:0" + currentTime; 
     } 
     else if (String(currentTime).length == 2) 
     { 
      recBar.counter.text = "00:" + currentTime; 
     } 
    } 

    private function recordComplete(e:Event):void 
    { 
     fileReference.save(recorder.output, recordedFileName); 
    } 
} 

,但對儲蓄,文件名是包含HTML文件的文件夾的名稱。

任何幫助將不勝感激。

回答

0

您沒有正確設置swfObject。

var flashvars = { }; 
    flashvars.fileName= "FILENAME_I_WANT_TO_USE"; 

var params = {}; 
    params.allowscriptaccess = "always"; 

var attributes = {}; 
    attributes.id = "flashContent"; 
    attributes.name = "flashContent"; 
    attributes.align = "middle"; 

var tmp = "expressInstall.swf"; 
var version = "9.0.0"; 
var width = "350"; 
var height = "350"; 
var container = "myAlternativeContent" 
var flashObj = "dev_LMP.swf?t=" + new Date().getTime() 

swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes); 
+0

我也建議使用版本11.3或11.4 –