0

I am using the following code from the Adobe ActionScript guide (Programming ActionScript 3.0 for Flex):

package { 
  import flash.display.Sprite; 
  import flash.media.Sound; 
  import flash.media.SoundChannel; 

  public class EmbeddedSoundExample extends Sprite { 
    [Embed(source="smallSound.mp3")] 
    public var soundClass:Class; 

    public function EmbeddedSoundExample()  { 
      var smallSound:Sound = new soundClass() as Sound; 
      smallSound.play(); 
    } 
  }
} 

The resulting swf refuses to play, tested on two different machines with two different operating systems (one WinXP desktop, one Zenwalk laptop).

Does anyone have a better example of embedding mp3s using Flex SDK (i.e. not FlashBuilder or CSx).

Thanks

ketan
  • 19,129
  • 42
  • 60
  • 98
Tarkin
  • 313
  • 2
  • 9
  • Your syntax looks correct. You might try it with some other mp3 files. You might have [issues with some mp3 files](http://stackoverflow.com/a/7977094/398606) because of the way they are encoded. With some formats, embedding the mp3 even fails and the code cannot be compiled. – Sunil D. Feb 02 '13 at 07:45

1 Answers1

0

As it turns out, mxmlc wasn't embedding my assets until I invoked it with the following switch:

-static-link-runtime-shared-libraries=true

After that, the resulting swfs were fine.

I hope this helps someone else using flex SDK / mxmlc.

Tarkin
  • 313
  • 2
  • 9