One Button Stop/Start Action in Flash CS5
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:
- Open a new Flash document and set your stage properties.
- Import your audio and images to the Library.
- Place and position your graphic on the Stage.
- Convert your image to a button.
- 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. - Toggle back to SCENE 1 and copy/paste your button into SCENE 2.
- Toggle back and forth to make sure the buttons align from Scene to Scene.
- Return to SCENE 1.
- Go to WINDOW and open CODE SNIPPETS.
- Click once to select your button image on the Stage.
- Using the Code Snippets dialogue box, click the arrow next to the TIMELINE NAVIGATION folder to drop down the options.
- Double-click STOP AT THIS FRAME
- Then double-click CLICK TO GO TO SCENE AND PLAY
- Under the Actions tab, select the green text.
- 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—>>>
- Now, toggle to SCENE 2.
- Click once to select your button image on the Stage.
- From the Library, drag your sound onto the Stage.
- Extend the Frames in your Timeline to fit the length of the audio.
- Click once to select Frame 1.
- Click once to select your button image on the Stage.
- Using the Code Snippets dialogue box, click the arrow next to the AUDIO AND VIDEO folder to drop down the options.
- Double-click CLICK TO STOP ALL SOUNDS.
- The, under the TIMELINE NAVIGATION folder, double-click CLICK TO GO TO SCENE AND PLAY.
- Under the Actions tab, select the green text.
- 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) - Scroll through the Timeline until you reach the end of the audio.
- In the Actions layer, above the audio and button layer, select the next frame after the audio and insert a KEYFRAME.
- Using the Code Snippets dialogue box, under the TIMELINE NAVIGATION folder, double-click STOP AT THIS FRAME.
- Save, Publish and Play!!!
gaming…
[…]One Button Stop/Start Action in Flash CS5[…]…
How to become a werewolf in Skyrim…
[…]One Button Stop/Start Action in Flash CS5[…]…
I’m impressed, I have to admit. Rarely do I encounter a blog that’s
equally educative and entertaining, and let me tell you, you’ve hit the nail on the head. The issue is an issue that too few people are speaking intelligently about. I’m very happy
I found this in my hunt for something relating to this.
Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something.
I think that you can do with some pics to drive the message
home a bit, but instead of that, this is excellent blog. A great
read. I’ll certainly be back.