undefined method loadCompressedDataFromByteArray through a reference with static type flash.media:Sound

219 views Asked by At

I read How to play MP3 sound from buffer (ByteArray/Stream) in ActionScript 3?. And really want to do that.

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

My codes:

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();
}

But I get:

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.

Edit: Found out it works with mxmlc 4.6, but not with 4.0

1

There are 1 answers

0
BotMaster On

You are targeting an FP version < 11, target Flash Player 11 at least to have this method available.