Accessibility

Control how sound plays through the right and left speakers


Table of Contents

  • PDF Version
  • Switch the right and left speakers

    To switch the left and right speakers:

    1. Import a sound file into Flash.
    2. With the sound selected in the Library, from the Options menu in the Library panel, choose Linkage. The Linkage Properties dialog box opens.
    3. Select the Export for ActionScript check box, and give the sound a linkage identifier (Figure 2).
    conversationID

    Figure 2: This sound is identified in the Library as conversationID.

    1. Create a button symbol, place an instance of it on the Stage, and give it a name in the Property inspector.
    2. Select the first frame of the main Timeline, and open the Actions panel.
    3. Instantiate a new Sound object, as you did earlier in this chapter (Figure 3). Don’t specify a target movie clip for the parameter.
    Sound object is created

    Figure 3: The mySound_sound Sound object is created.

    1. Attach the sound to this Sound object with the method attachSound().
    2. Create an onRelease event handler for your button.
    3. Choose the start() method for your Sound object (Figure 4). This button plays your sound.
    startButton_btn is clicked

    Figure 4: The sound called conversationID plays five times when the button called startButton_btn is clicked.

    1. Place another instance of the button symbol on the Stage, and give it a name in the Property inspector.
    2. In the Actions panel, assign an onRelease event handler to the second button.
    3. Inside the event handler function, declare your transformation object by entering var, a name, and :Object followed by an equals sign.
    4. Choose ActionScript 2.0 Classes > Core > Object > “new Object.” Your new sound transformation object is instantiated (Figure 5).
    mySoundTransform is created

    Figure 5: Within the onRelease handler for the button called transformButton_btn, the object mySoundTransform is created as an instance of the generic Object class.

    1. On the next line of the onRelease event, enter the name of your sound transformation object followed by a period and then one of the properties. Enter an equals sign and then a number representing the percentage for that property. Do this for all four properties (Figure 6). The properties of your sound transformation object are defined. These properties will be used by the setTransform() method.
    four properties

    Figure 6: In the onRelease handler for the button called transformButton_btn, the four properties to be used by the setTransform() method are defined as properties of the object mySoundTransform.

    1. On the next line, still inside the onRelease event, enter the name of your Sound object followed by a period.
    2. Choose ActionScript 2.0 Classes > Media > Sound > Methods > setTransform.
    3. With your pointer between the parentheses, enter the name of your sound transformation object (Figure 7).
    add the setTransform() method

    Figure 7: In the onRelease handler for the button called transformButton_btn, add the setTransform() method with the object mySoundTransform as its parameter. The four properties of the mySoundTransform object supply the method with the information required to distribute the sound to the left and right speakers.

    1. 18 Test your movie. When you click the second button, Flash creates a generic object whose properties (mySoundTransform.ll, mySoundTransform.lr, and so on) hold the sound transformation information. This information is then used by the setTransform() method to change the distribution of sound in the left and right speakers.

    Where to go from here

    For more information about working with sound in Flash, see the following articles: