0 Replies Latest reply: Mar 27, 2013 3:35 PM by Swhites RSS

    How to import and play sound file from mxl link?

    Swhites

      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.mp3</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.mp3";

                                                        var request:URLRequest = new URLRequest(urlSong);

                                                        bSong = new Sound(request, context);

                                                        bSong.play();

       

      }

        ]]>

      </fx:Script>