|
|
Labs.byHook |
Flash Scripts, Tools & Methods Developed at Hook |
Sound is one of the areas in Flash that seems to cause the most frustration. The included sound classes are adequate for basic playback but don’t provide enough capability on their own for larger projects. The area we found to be most lacking is in organization and management of lots of sounds. In order to get the level of control we have needed for client projects we created our SoundManager system.
The SoundManager is a system designed to simplify working with sound in Flash. SoundManager enables you to work with sound individually, in groups or globally. This makes dealing with large numbers of sounds much easier. SoundManager is built in Actionscript 3 and works with Flash Player 9 and above.
Getting Started
The 3 main classes are SMSound, SoundController and SoundManager. These provide you with the multiple levels of control. The system operates as a basic hierarchy with the SoundManager Singleton acting as the global sound control, and calling methods on its list of SoundControllers, which in turn call methods on their SMSounds. All of these objects can work together or individually. A SMSound can be created and used on its own. Likewise the SoundController does not need the SoundManager to function.
SMSound is an object that represents the actual sound object in the library. This manages the states and access to the embedded sound object. This wraps flash.media.Sound to provide easier control. It is recommended that all SMSound objects be controlled through a SoundController. However, SMSound objects can function on their own in a limited capacity.
SoundController is intended to manipulate individual SMSounds or groups of SMSounds. Each SoundController contains a list of SMSound objects that can be controlled. This provides the ability to controls groups of sounds.
SoundManager is the global controller for all sounds. The SoundManager is used to manage a list of SoundController objects. Methods called on the SoundManager will be applied to all of the contained SoundControllers.
SoundManager makes use of the Greensock Tweening Platform for fading effects. You can find documentation and licensing information for that here.
SoundManager currently supports the ability to set volume but not panning. That will be supported in a later version.
Here is a quick example of how to set up the system. More detailed examples are included below.
import com.jac.soundManager.ISMSound; import com.jac.soundManager.SMSound; import com.jac.soundManager.SoundController; import com.jac.soundManager.SoundManager; private var _soundManager:SoundManager = SoundManager.getInstance(); private var _soundController:SoundController; private var _testSound:ISMSound; //Make new SoundController to control the sound with.. _soundController = new SoundController("controller1"); //Add the new SoundController to the SoundManager for global control _soundManager.addSoundController(_soundController); //Create a new SMSound object to be controlled by _controller _testSound = new SMSound("sound1", "cheer", true); //Add the new sound to the SoundController _soundController.addSound(_testSound); //Play a specific sound by ID with various options. //To Play the entire controller you can use _soundController.PlayAllSounds() _soundController.play("sound1", SoundController.NO_VOLUME_CHANGE, 0, SoundController.AUTO_LOOP);
Code, documentation and examples can be found here.
This product is licensed under GPLv3.
Oh my goodness! an amazing article. Thank you!
North American Hockey League (NHL) 4 finals in the second end of Vancouver Rogers Stadium. Vancouver Canucks first goal in extra time, so that rivals the Boston Bruins ‘sudden death’, which ended 3-2 victory and 2-0 total points in the Stanley Cup finals to stay ahead. Winning goal by striker Abel Ross added 11 seconds left in overtime when hit. At that time, he received a pass from his teammates quickly advancing from the left wing, escaped Bruins goalie Tim Thomas of the block.
Thanks a lot for sharing this amazing knowledge with us. This site is fantastic. I always find great knowledge from it.
Вежливые грузчики только здесь