ProblemYou've created a Sound object and started streaming a sound file into it. Now you want to play it and eventually stop it. SolutionUse the play( ) method to start the sound playing. Use the close( ) method to stop the sound from streaming. DiscussionPlaying a sound which has been loaded into a Sound object is very easy. Simply call the play( ) method of that Sound object, like so: _sound = new Sound(new URLRequest("song.mp3")); _sound.play( ); It is that simple. There are some additional optional parameters to the play( ) method, which are covered in Recipes 15.1 and 15.10. The close( ) method of the Sound object not only stops the sound from playing, but also stops the streaming of the sound file. To play that sound again, call the load( ) method to restart loading the sound data. The close( ) method should be called only when you are sure you are finished with that particular sound. Recipe 15.1 discusses a way to stop the sound from playing without stopping the stream, using the SoundChannel class. See AlsoRecipe 15.1 for information on how to load external sound files and Recipe 15.10. |