Quantumwave Interactive Inc.
  Interactive media development . Programming . Design . Consulting

qwiSndObj (Flash 5)

In Director, there is a sound function isBusy() used for detecting if a particular sound channel is playing or not. This function is missing in Flash 5. What this movie clip object does is implement a similar function by adding new methods to the Sound object.


Usage
:

Drag the qwiSndObj movie clip from the shared Library "qwiSndObj" to the stage (usually outside of it).

There are two ways to use this object:

1) Select the qwiSndObj movie clip instance and give it a name. Change the sound properties in the Clip Parameters panel:

- sndID : name of sound linkage ID
- sec : number of seconds of the sound (under Library/Sound Properties)
- secOffset : seconds offset to start playing (0 to start from beginning)
- nLoop : number of times to loop the sound
- autoStart : if this is equal to "true" then sound starts automatically

Call method: <qwiSndObj instance name>.methodName()
e.g. if (sndObj.isBusy()) { do whatever }

2) Create a new sound object in script:

var mySnd = new Sound(level);
// specify the level or use 'this' (if it is referring to the current timeline)
// this ensures the sound will still play if the movie is loaded into a different level

Call method: <Sound object>.methodName()
e.g. mySnd.init(sndID, sec, secOffset, nLoop, autoStart);
if (mySnd.isBusy()) { do whatever }


Version
:

1.01 - Dave Yang / Quantumwave Interactive Inc.


Note:

You must specify all parameters in this version.


Public methods
:

Call by <Sound object name>.methodName():

init(sndID, sec, secOffset, nLoop, autoStart) -- use with script-defined "new Sound()" objects
startSnd()
stopSnd()
isBusy()
getSndEndTime()

Call by <qwiSndObj instance name>.methodName():

startSnd()
stopSnd()
isBusy()
getSndEndTime()


Example
:

In this movie, the qwiSndObj movie clip instance is named "sndObj".

To start the sound named "sndLoop" specified in the clip parameter:

sndObj.startSnd();

To check if the sound has finished playing:

if (sndObj.isBusy()) { do whatever }

or

if (!sndObj.isBusy()) { do something else }

To get the time when the sound is supposed to finish:

sndObj.getSndEndTime();

To stop the sound:

sndObj.stopSnd();

Another sound in this movie is created like this:

mySnd = new Sound(this);
mySnd.init(sndID, sec, secOffset, nLoop, autoStart);

Apply the new methods and functions:

mySnd.isBusy()
mySnd.getSndEndTime();

The "mySnd Vol" button toggles between 25% & 100% sound volume.

When the movie starts, mySnd starts playing automatically. When it is done, another sound mySnd2 (14 seconds long) automatically starts playing from an offset at 12 seconds and loops twice. At the end of mySnd2, mySnd3 starts playing and it is the same sound as the first sound, except it loops twice and is started using startSnd().


Download .fla source file
:

qwiSndObj.zip (7K - shared library only)

test_qwiSndObj.zip (2281K - test movie + shared library)


home | about | news | flash | director | shockwave | download | dave | résumé | contact

Copyright © 1995-2009 Quantumwave Interactive Inc.