g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Natural Living
Folklore and Mythology
Distance Learning

All times in EST

Full Schedule
g Flash and Animation Site

BellaOnline's Flash and Animation Editor


Sound with ActionScript - Flash Storybook App

    With that in mind, we want the reader to be able to play the sound file immediately when the app begins. The ActionScript that plays the sound must run when the app loads. To be sure the code runs immediately, we will place the code on the first frame of the Timeline.

    Note: Any code placed on other frames of the Timeline will run when Flash enters that frame. This is one way to control the timing for your code.

  1. Add a new layer at the top of the Timeline and name it "actions". Click on the first frame of the actions layer and then open the Actions Panel. Type the following code in the blank box.

// redOrn button

redOrn.addEventListener(MouseEvent.CLICK, redOrnSound);

function redOrnSound (event:MouseEvent):void {

var jinglbellSound:jinglbell = new jinglbell();
var jinglbellChannel:SoundChannel = new SoundChannel();
jinglbellChannel =;
jinglbellChannel = null;
jinglbellSound = null;


Many effects in Flash are controlled by Event Listeners, which listen for a certain event (such as a mouse click) and then run a section of code called a function. Above, we first have added an Event Listener to the redOrn movie clip that will run the function called redOrnSound.

In the reOrnSound function is the code that will play the sound file named jinglbell.

  1. The first line of code in the function creates a variable to hold the name of the sound file and a new instance of the sound.

    var jinglbellSound:jinglbell = new jinglbell();

  2. The second line of code creates a variable to hold the name of the sound channel for the sound and creates a new instance of the sound channel.

    var jinglbellChannel:SoundChannel = new SoundChannel();

  3. The third line of code associates the sound channel to the sound and plays the sound.

    jinglbellChannel =;

    All that just to play a simple sound. Welcome to object-oriented programming.

  4. The last two lines of code set the two variables to null to save memory storage space for our app.

    jinglbellChannel = null;
    jinglbellSound = null;

Repeat these steps for the other two ornaments.

More about symbols: Symbols are the building blocks of Flash. There are three types of symbols, movie clip, button and graphic. The button symbol is different from the other two because it has a special four-frame Timeline. The other two symbol types have a Timeline like the main Timeline that we have been working on. For simple buttons, using the Button symbol and its special Timeline is sufficient. But for complex buttons such as the one we created above, we need to add ActionScript to make the movie clip function as a button.

← Back

Join us in the Digital Art and Design forum. | Join us in the Flash forum.

Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Twitter Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Facebook Add Sound+with+ActionScript+%2D+Flash+Storybook+App to MySpace Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Digg Sound+with+ActionScript+%2D+Flash+Storybook+App Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Yahoo My Web Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Google Bookmarks Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Stumbleupon Add Sound+with+ActionScript+%2D+Flash+Storybook+App to Reddit


RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the Flash and Animation Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2018 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.


g features
Subtle Animation Website Trends

Wix Editor - Background Video

Video on Wix Websites

Archives | Site Map


Past Issues

Note: BellaOnline uses cookies to help provide a consistent user experience. Our advertisers may use cookies to help customize ads. Please contact us with any question about our cookie use.

Summertime Foods
Corn on the Cob
Burgers on the Grill
Apple Pie


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2018 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor