I am by far, the last person you would want to ask about coding…but, on the rare occasion I can even surprise myself with what I can figure out if I keep at it long enough!

The Issue: I am creating a course for a client and they are using icons that let the end-user know there is additional text to read or audio to play. Because these are icons, I needed to create a button from this image that would play the audio on the first click, and then stop the audio on the second click. I am sure there are easier ways to do this with actionscripting, but again, I am not a code guru, so here is the solution I came up with.

My solution:

  1. Open a new Flash document and set your stage properties.
  2. Import your audio and images to the Library.
  3. Place and position your graphic on the Stage.
  4. Convert your image to a button.
  5. Go to INSERT and choose SCENE.

    On the left, you will actually see SCENE 2, but you can toggle back and forth between the Scenes using the Scene toggle button on the right.
  6. Toggle back to SCENE 1 and copy/paste your button into SCENE 2.
  7. Toggle back and forth to make sure the buttons align from Scene to Scene.
  8. Return to SCENE 1.
  9. Go to WINDOW and open CODE SNIPPETS.
  10. Click once to select your button image on the Stage.
  11. Using the Code Snippets dialogue box, click the arrow next to the TIMELINE NAVIGATION folder to drop down the options.
  12. Double-click STOP AT THIS FRAME
  13. Then double-click CLICK TO GO TO SCENE AND PLAY
  14. Under the Actions tab, select the green text.
  15. At the top of the Actions window, in the Parameters field, change the Scene # to 2.
    (NOTE: You can also select CLICK TO GO TO NEXT SCENE)
     

    This is how the Timeline for Scene 1 should look—>>>

  16. Now, toggle to SCENE 2.
  17. Click once to select your button image on the Stage.
  18. From the Library, drag your sound onto the Stage.
  19. Extend the Frames in your Timeline to fit the length of the audio.
  20. Click once to select Frame 1.
  21. Click once to select your button image on the Stage.
  22. Using the Code Snippets dialogue box, click the arrow next to the AUDIO AND VIDEO folder to drop down the options.
  23. Double-click CLICK TO STOP ALL SOUNDS.
  24. The, under the TIMELINE NAVIGATION folder, double-click CLICK TO GO TO SCENE AND PLAY.
  25. Under the Actions tab, select the green text.
  26. At the top of the Actions window, in the Parameters field, change the Scene # to 1.
    (NOTE: You can also select CLICK TO GO TO PREVIOUS SCENE)
  27. Scroll through the Timeline until you reach the end of the audio.
  28. In the Actions layer, above the audio and button layer, select the next frame after the audio and insert a KEYFRAME.
  29. Using the Code Snippets dialogue box, under the TIMELINE NAVIGATION folder, double-click STOP AT THIS FRAME.
  30. Save, Publish and Play!!!