2015-06-10 48 views
0

我讀How to play MP3 sound from buffer (ByteArray/Stream) in ActionScript 3?。真的想要這樣做。未定義方法loadCompressedDataFromByteArray通過靜態類型的引用flash.media:Sound

從Adobe:http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/media/Sound.html#loadCompressedDataFromByteArray()

我的代碼:

private function playBase64(content:String):void { 
    var mp3Bytes:ByteArray; 
    var mp3Sound:Sound = new Sound(); 
    mp3Bytes = Base64.decodeToByteArray(content); 
    mp3Bytes.position = 0; 
    mp3Sound.loadCompressedDataFromByteArray(mp3Bytes, mp3Bytes.length); 
    mp3Sound.play(); 
} 

,但我得到:

Warning: Running "mxmlc:all" (mxmlc) task 
    >> Error: Command failed: /Users/michaeljin/git/yinlang/training/node_modules/flex-sdk/lib/flex_sdk/bin/mxmlc -debug=true -optimize=true -library-path=client/assets/flash/libs -output client/assets/flash/YLSoundPlayer.swf -- client/assets/flash/YLSoundPlayer.as 
    >> /Users/michaeljin/git/yinlang/training/client/assets/flash/YLSoundPlayer.as(59): col: 16 Error: Call to a possibly undefined method loadCompressedDataFromByteArray through a reference with static type flash.media:Sound. 
    >> 
    >>  mp3Sound.loadCompressedDataFromByteArray(mp3Bytes, mp3Bytes.length); 
    >>    ^
    Warning: FAILED Use --force to continue. 

    Aborted due to warnings. 

編輯:發現了它的工作原理與mxmlc的4.6,而不是4.0

+0

如果你引用了你認爲與函數的文檔相關的內容,那麼所有的文本都不會比你發佈的鏈接長得多...... – eirikdaude

+0

我認爲這種方法存在,它顯示在adobe中該文件。但它不適合我。 – emj365

+0

也許你編碼的字符串不解碼成有效的MP3? Flash支持轉換爲'Sound'對象的MP3有限制。 – Vesper

回答

0

您的目標是FP版本< 11,目標Flash Player 11至少有這個方法可用。

相關問題