Hello :)

I use in my opensource framework a model to register all sounds in my
application and manipulate all sounds.

The SoundLibrary class :
http://svn1.cvsdude.com/osflash/vegas/AS2/trunk/src/andromeda/media/SoundLibrary.as

See the example of the class :

import andromeda.events.SoundModelEvent ;
import andromeda.media.SoundLibrary ;
import vegas.events.Delegate ;

var debug:Function = function ( e:SoundModelEvent ):Void
{
   var type:String = e.getType() ;
   var id:String = e.getID() ;
   var library:SoundLibrary = SoundLibrary(e.getModel()) ;
   var sound:Sound = e.getSound() ;

   var message:String = "> " + library ;
   message += " " + type ;
   if (id != null)
   {
       message += ", id:" + id ;
   }
   if (sound != null)
   {
       message += ", sound:" + sound ;
   }
   trace( message ) ;
}

var lib:SoundLibrary = new SoundLibrary() ;
lib.addGlobalEventListener( new Delegate(this, debug) ) ;

lib.addSound( "sound_1" ) ; // sound_1 is the link name of the sound
in the library
lib.addSound( "sound_2" ) ;

// lib.addSounds( ["sound_1", "sound_2"] ) ; // use this method to
register a array collection of sounds ids.

trace("> " + lib + " size : " + lib.size()) ;

Key.addListener(this) ;

var onKeyDown:Function = function()
{
   var code:Number = Key.getCode() ;
   switch ( code )
   {
       case Key.UP :
       {
            lib.getSound( "sound_1" ).start() ;
            break ;
       }
       case Key.DOWN :
       {
           lib.getSound( "sound_2" ).start() ;
          break ;
       }
       case Key.SPACE :
       {
          lib.toggle() ; // enable/disable all sounds
          break ;
       }
    }
}

trace("> Press Key.SPACE to disable/enable the library.") ;
trace("> Press Key.UP to start the sound_1 sound.") ;
trace("> Press Key.DOWN to start the sound_2 sound.") ;


See the online documentation :

http://vegas.ekameleon.net/docs/andromeda/media/SoundLibrary.html

Page project : http://code.google.com/p/vegas/
Install VEGAS with this SVN repository in osFlash :
http://code.google.com/p/vegas/wiki/InstallVEGASwithSVN

EKA+ :)

2007/9/12, Ian Thomas <[EMAIL PROTECTED]>:
>
> Each Sound() object is attached to a particular timeline.
>
> So if you do :
>
> (new Sound(_root)).stop()
>
> everything from _root downwards should stop.
>
> HTH,
>    Ian
>
> On 9/11/07, Andrew Sinning <[EMAIL PROTECTED]> wrote:
> >
> > I don't understand the docs for the AS2 Sound.stop command.
> >
> > > my_sound.stop(["idName":String]) : Void
> >
> > I can't find any documentation about sounds having an "idName".
> >
> > >Method; stops all sounds currently playing if no parameter is
> > specified, or just the sound specified in the idName parameter.
> >
> > But "my_sound" is an instance of the Sound class, so why would I need to
> > specify an id?  This seem to imply that I could use
> >
> >     Sound.stop();
> >
> > to stop all sounds currently playing.  But it won't compile.  I get
> > "Sound has no static field stop".
> >
> > So, how do you stop all currently playing sounds?
> >
> > Thanks!
> >
> >
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to