7 Replies Latest reply: Oct 1, 2012 12:42 PM by kglad RSS

    How do I pass a string variable from a movieclip timeline to a url request inside of a class?

    DanEdmonds Community Member

      Hello,

       

      I've coded an audio player class I'd like to be able to reuse throughout my project to play a different sound in each movieclip. The audio player works great and the sound loads when I request the url from within the class but I'm having trouble requesting the url coded on the parent movieclip's timeline.

       

      I have an instance of a movieclip named musicPlayer in 4 different parent movieclips that is linked to a class named MusicPlayer which contains my audio player code.

       

      To test, in one of the parent movieclips, I've placed the following code to set the url path to a string variable:

       

      var mp3url = "tuba.mp3";
      

       

      Then, in my class I've declared the same variable as a string:

       

      public var mp3url:String;

       

      and tried passing it to my url request:

       

      mp3File.load(new URLRequest(mp3url));

       

      I'm then receiving an error: "1151: A conflict exists with definition mp3url in namespace internal."

       

       

      As mentioned above, the sound is loaded perfectly when I set the url path to a string variable within my class like so:

       

      public var mp3url:String = "tuba.mp3";

       

       

      Thank you in advance!