Home arrow Flash arrow Page 4 - Basic Flash ActionScript for Designers
FLASH

Basic Flash ActionScript for Designers


If you already know the basics of Flash, using tools and creating animations, you may want to add some interactivity to your work. ActionScript, an object oriented programming language built into Flash, is the key to this. Adi Reddy Mora explains the basics of ActionScript.

Author Info:
By: Adi Reddy Mora
Rating: 4 stars4 stars4 stars4 stars4 stars / 193
June 01, 2005
TABLE OF CONTENTS:
  1. · Basic Flash ActionScript for Designers
  2. · Buttons, Movie Clips, and Making them Draggable
  3. · Navigating, URLs, and Loading Images
  4. · Loading External MP3 Files

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Basic Flash ActionScript for Designers - Loading External MP3 Files
(Page 4 of 4 )

As far as audio files, Flash player supports only the MP3 file format. To load MP3 files at runtime, you need to use the loadSound() method of the Sound class. First, you need to create a Sound object, as shown in the following sample where "song1" is the instance of the sound object:

var song1:Sound = new Sound();

Then you need to use the loadSound() method of the sound object to load an event or a streaming sound. Event sounds are loaded completely before being played; streaming sounds play as they are downloaded. The isStreaming parameter of loadSound() can specify a sound as an event sound or a streaming sound.

After you load an event sound, you must call the start() method of the Sound class to make the sound play. Streaming sounds begin playing automatically, so you don't need start().

song1.loadSound("lastchristmas_wham.mp3", false);song1.start();

In the above sample, the first parameter is the mp3 file path and the send parameter is the isStreaming value, either true or false.

I recommended setting the isStreaming parameter to true, especially when you are loading large sound files so that the file starts playing as soon as possible.

To determine when a sound has completely downloaded, use the Sound.onLoad event handler. This event handler automatically receives a boolean value that indicates whether the file downloaded successfully.

song1.onLoad = function(success){
};

“Success” is the parameter which returns either true or false.

This article has covered most of the basics for adding interactivity to Flash movies for designers who don’t have any previous ActionScript knowledge. However there are a lot more features available for designers to learn, given enough ambition and patience.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials