0 Replies Latest reply on May 19, 2006 10:46 AM by _Gary

    Loading Sound on the Fly

    _Gary
      I'm trying to load a sound based on a variable specified by Javascript. I'm having trouble making things work when I move the loadSound statement into a function. Maybe this is just a question of scope, but I've tried every combination of _global and _root and so forth, but I can't get it to work. The following examples are simplified to illustrate the problem (ultimately I'll pass info for song selection)...

      This works fine:

      var m1:Sound=new Sound();
      m1.loadSound("stringdub.mp3",true);

      function playMusic()
      {
      m1.start();
      }
      ExternalInterface.addCallback("playMusic", this, playMusic);

      But this fails (the onlly change is that loadSound is now in the function):

      var m1:Sound=new Sound();

      function playMusic()
      {
      m1.loadSound("stringdub.mp3",true);
      m1.start();
      }
      ExternalInterface.addCallback("playMusic", this, playMusic);