1 Reply Latest reply on May 20, 2006 4:45 PM by NSurveyor

    Uh Oh -- Wrong way to do this?

    Angyl
      I'm building an alphabet game for my daughter. Instead of building 26+ (for the different phonics) symbols of the letters, I started by creating ONE instance of a movie with a dynamic text field in it and I'm using code to assign the value of the text field. Like:

      LetterB1.LetterInside.LetterText.text = "B";
      LetterC1.LetterInside.LetterText.text = "C";
      LetterD1.LetterInside.LetterText.text = "D";

      etc...

      It just occured to me, after I broke up all the different recordings of the letters, that I have no way of assigning the Buh sound to the instance "LetterB1" and the Duh sound to the instance "LetterD1" etc.

      I'm betting it can be done, I just don't know how. The alternative, of course, is to start over and indeed make every letter its own symbol and simply attach the proper sound to it manually.

      I'd rather not start over. Help, please?
        • 1. Re: Uh Oh -- Wrong way to do this?
          NSurveyor Level 2
          You can use the Sound class. I'm thinking something like this:

          mySound = new Sound();
          //
          addSound(LetterB1,"B");
          addSound(LetterC1,"C");
          addSound(LetterD1,"D");
          //
          function addSound(clip,linkage){
          clip.onPress = function(){
          mySound.attachSound(linkage);
          mySound.start(0);
          };
          }

          Also, open up the library. For each sound, right click, and select Linkage. Check off the box, Export for ActionScript. Then type in the name you want the sound to have. In the line of code: addSound(LetterB1,"B"); LetterB1 will play the clip with linkage id, "B".

          If you are more specific on the names of the instances you want to make, and the names of the sounds, etc. there may be a way to accomplish what you need entirely programmatically with just one clip.