Flash
  Home arrow Flash arrow Page 5 - Adding Video and Sound
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Adding Video and Sound
By: Bill Sanders
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2004-07-12

    Table of Contents:
  • Adding Video and Sound
  • Importing and Setting Sounds
  • Setting Sound Properties
  • Adding Sounds to Movies
  • Using the Sound Class
  • Project: Experimenting with Sound
  • Using Media Components
  • Working with Media Classes
  • NetStream Controls

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Adding Video and Sound - Using the Sound Class


    (Page 5 of 9 )

    The code generated by the Behaviors panel shows how Flash Pro uses the many different elements of the Sound class. Tables 10.3–10.5 summarize the methods, properties, and events, respectively, of the Sound class.

    Table 10.3 Sound Class Methods

    Method

    Actions

    soundInst.attachSound("id")

    Attaches the sound identified by the linkage name id to the instance.

    soundInst.getBytesLoaded()

    Returns the number of bytes in the sound instance that's currently loaded.

    soundInst.getBytesTotal()

    Returns the total number of bytes in the sound instance.

    soundInst.getPan()

    Returns the current pan value established by setPan().

    soundInst.getTransform()

    Returns the value from the last setTransform() call.

    soundInst.getVolume()

    Returns the current volume setting.

    soundInst.loadSound("url", Boolean)

    Loads the MP3 file identified by url with the option of streaming (Boolean true) or event (Boolean false).

    soundInst.setPan(n)

    The pan value (n) is set in terms of negative values up to –100 for the left speaker and positive values up to 100 for the right speaker. Mid balance is 0.

    soundInst.setTransform(Obj)

    Establishes the amount of the two channels that will be played in left and right speakers. (Obj is an object containing the channel properties for left/right speakers.)

    soundInst.setVolume(n)

    The volume (n) can be set from 0 to 100, where 0 indicates the sound is off.

    soundInst.start(s,l)

    The sound begins playing with these optional parameters: start position in seconds (s) and number of times to loop (l).

    soundInst.stop()

    Only stops the sound instance's sound.


    Table 10.4 Sound Class Properties

    Property

    Characteristics

    soundInst.duration

    Returns the number of milliseconds in a sound instance.

    soundInst.id3.tagName

    A read-only property to access different ID3 1.0/2.0 tags (tagName) in an MP3's metadata.

    soundInst.position

    Returns the number of milliseconds for which a sound has been playing.


    Table 10.5 Sound Class Events

    Event

    Description

    soundInst.onID3

    Fires after the load sequence and ID3 data become available.

    soundInst.onLoad

    When a sound is loaded, the event fires.

    soundInst.onSoundComplete

    Fires once the sound has stopped playing.


    The Sound class provides two methods to access sound: attachSound() and loadSound(). When you use attachSound(), you need to first import a sound into the Library panel and give it a linkage name. Using loadSound(), you can load the sound file directly from the server, either as an event sound or a stream sound. When you select a stream sound, the sound begins playing shortly after the loading begins.

    All instances of the Sound class must first be instantiated using the Sound constructor, such as in the following line:

    var soundBarrier:Sound = new Sound();

    Once the Sound class is instantiated, its different methods, properties, and events can be attached to the instance. Using the Sound class, you have far more control over sound than with any other technique available in Flash Pro.

    This chapter is from Macromedia Flash MX Professional 2004, by Bill Sanders (Sams, 2004, ISBN: 0672326051). Check it out at your favorite bookstore today.

    Buy this book now.

     

    More Flash Articles
    More By Bill Sanders


       · Thanx for taking the time to write this verry useful tutorial.. you helped me so...
     

    FLASH ARTICLES

    - 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
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT