View Full Version : Control Sound Object
puthisorn
05-05-2004, 12:24 AM
I want to know the script that control sound object to play, pause and stop.
Anyone please tell me with example.
agent81
05-05-2004, 03:03 AM
from the actionscript dictionary.
(probably faster to go straight there :)
Sound class
Availability
Flash Player 5.
Description
The Sound class lets you control sound in a movie. You can add sounds to a movie clip from the library while the movie is playing and control those sounds. If you do not specify a target when you create a new Sound object, you can use the methods to control sound for the whole movie.
You must use the constructor new Sound to create a Sound object before calling the methods of the Sound class.
Method summary for the Sound class
Method
Description
Sound.attachSound()
Attaches the sound specified in the parameter.
Sound.getBytesLoaded()
Returns the number of bytes loaded for the specified sound.
Sound.getBytesTotal()
Returns the size of the sound in bytes.
Sound.getPan()
Returns the value of the previous setPan() call.
Sound.getTransform()
Returns the value of the previous setTransform() call.
Sound.getVolume()
Returns the value of the previous setVolume() call.
Sound.loadSound()
Loads an MP3 file into Flash Player.
Sound.setPan()
Sets the left/right balance of the sound.
Sound.setTransform()
Sets the amount of each channel, left and right, to be played in each speaker.
Sound.setVolume()
Sets the volume level for a sound.
Sound.start()
Starts playing a sound from the beginning or, optionally, from an offset point set in the parameter.
Sound.stop()
Stops the specified sound or all sounds currently playing.
Property summary for the Sound class
Property
Description
Sound.duration
Length of a sound, in milliseconds.
Sound.ID3
Provides access to the metadata that is part of an MP3 file.
Sound.position
Number of milliseconds a sound has been playing.
Event handler summary for the Sound class
Event handler
Description
Sound.onID3
Invoked each time new ID3 data is available.
Sound.onLoad
Invoked when a sound loads.
Sound.onSoundComplete
Invoked when a sound stops playing.
Constructor for the Sound class
Availability
Flash Player 5.
Usage
new Sound([target])
Parameters
target The movie clip instance on which the Sound object operates. This parameter is optional.
Returns
Nothing.
Description
Constructor; creates a new Sound object for a specified movie clip. If you do not specify a target instance, the Sound object controls all of the sounds in the movie.
Example
The following example creates a new Sound object called global_sound. The second line calls setVolume() and adjusts the volume on all sounds in the movie to 50%.
global_sound = new Sound();
global_sound.setVolume(50);
The following example creates a new Sound object, passes it the target movie clip my_mc, and calls the start method, which starts any sound in my_mc.
movie_sound = new Sound(my_mc);
movie_sound.start();
farafiro
05-05-2004, 05:38 AM
http://www.kennybellew.com/tutorial/
Mortimer Jazz
05-05-2004, 01:26 PM
*chuckles at agent81*
That Kenny Bellow tutorial is good. There is also some useful info in Moock's "Actionscript Definitive Guide" if you have it. The sound object is [still] quite buggy in places even in MX04 and you may need to use a setInterval function to 'poll' for information if you're using Sound.position and/or Sound.duration.
Agent - don't know what's happened to the "pm" buttons on these forums. Any chance you could give me a quick shout (mailto:neil@nwebb.co.uk) ?
farafiro
05-06-2004, 01:49 AM
*chuckles at agent81*
Agent - don't know what's happened to the "pm" buttons on these forums. Any chance you could give me a quick shout (mailto:neil@nwebb.co.uk) ?
hey Mort
u were away for a long time now
http://www.actionscript.org/forums/showthread.php3?t=45578
Mortimer Jazz
05-06-2004, 03:08 AM
Hey Faffy, yeah I've been a little busy with my site recently, but I've been lurking a little :]
How's you?
farafiro
05-06-2004, 03:50 AM
me, lol
if I think a little about this question, I may die
lol
but I'm okey, alive
very busy with my work here (in the stock MKT)
can't read any more about MX 2004 :(
this is all
yo??
Mortimer Jazz
05-06-2004, 04:05 AM
not bad - looking for a job at the moment. Lots of emails, forms and phonecalls. Oh the joy, it's so much fun! I wonder when we'll get PM back! Thanks for the link, I thought I was going mad. Keep your head up :]
farafiro
05-06-2004, 04:17 AM
what do u mean by getting the PN back??
click on the name of any member, and you will get a menu of the usefull links
Mortimer Jazz
05-06-2004, 04:20 AM
private messaging - the thing you sent me the link about! Oh, yeah I see - thanks.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.