Skip navigation
Swhites
Currently Being Moderated

How to import and play sound file from mxl link?

Mar 27, 2013 3:35 PM

Tags: #and #file #link #import #sound #play #from #mxl

I need to load different sound files dependent on which link you previously clicked in my app, but cannot figure out how to call the link to the sound file from my mxl file:

 

<carRace>http://www.unisux.org/zik-car/lamborghini-diablo-gtr_standing-start.mp 3</carRace>

 

Can someone tell me what I am doing wrong in this code?

 

<fx:Script>

   <![CDATA[

                                        private var req:URLRequest;

                                        private var context:SoundLoaderContext = new SoundLoaderContext(1000);

                                        private var bCall:Sound;

                                        private var bSong:Sound;

 

  private function playSong():void

                                        {

                                                  var urlSong:String = "{carRace}";

                                                  var request:URLRequest = new URLRequest(urlSong);

                                                  bSong = new Sound(request, context);

                                                  bSong.play();

                                        }

  ]]>

</fx:Script>

 

 

because this code does work:

 

<fx:Script>

   <![CDATA[

  private var req:URLRequest;

  private var context:SoundLoaderContext = new SoundLoaderContext(1000);

  private var bCall:Sound;

  private var bSong:Sound;

 

  private function playSong():void

                                        {

  var urlSong:String = "http://www.unisux.org/zik-car/lamborghini-diablo-gtr_standing-start.mp 3";

                                                  var request:URLRequest = new URLRequest(urlSong);

                                                  bSong = new Sound(request, context);

                                                  bSong.play();

 

}

  ]]>

</fx:Script>

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points