Recording+and+Using+Audio+in+CLIPS+Activities

Main CLIPS Page Recording and Preparing Audio

Adding Sound to Activities

 * Note for Flashfest 2010**
 * Download the appropriate fla from flashfest.
 * Do a quick run through with the fla and the version at [|www.mathclips.ca] to make sure it is current

To add sound to a document that uses a standard activity template - see the notes in the globals and sound layer of the activity template and the ZenDocs for activities_01.as @http://www.isenegger.ca/tapatoo/docs/examples/documented/edu/clips/actions/activities_01.html

1) Open the file in CS3 and check that FlashPlayer 8, Actionscript 2 is targeted

2) Go to File | Publish Settings and target the correct .swf path - for audio testing, clicking on "Use Default Names" is likely sufficient.

3) Go to Actions (F9) global:Frame 1 at the activity(_root) level and make sure the code looks like: code format="actionscript" 18 //whether to use narration - usually true when published 19 var usingNarration:Boolean = true; 20 21 // set this variable to false if no narration added yet to draft ... 22 var narrationExists:Boolean = true; code

4) Click on File/Import/Import to Library --> browse to the location of the sound files, select the appropriate files and then click "Import to Library"

5) Open the Library (F11) of the activity, move the narration files to the narration folder - you can multiple select and drag

6) right click on each narration file, select "Linkage", click "Export for ActionScript (which will select Export in first frame and make the linkage name the same as the filename) - to do this quickly right-click, press L, press space, press Enter. In CS4, you will have to select "Properties" to get the Linkage information.

7) Open Actions (F9) and navigate to your scene and to globals & sound:Frame 2. Add the linkage name of your file to where it says "InsertSoundFileNameHere.mp3" Note: if the definition of sound "right" along with the function pingCorrect appear on frame 2; cut and move it to the end of frame 1 of the globals layer; this will interfere with the playing of your narration (your narration will start but defineNewSoundEffect will immediately stop it) - also you might want to change the right.startSoundEffect line to use volume percent 10 - see code below.

8) revise the settings in setPauseAndSoundFinished to match that of with no narration, the one exception the second Boolean refers to sound and it must be true; select a finished setting for the sound (generally disablepause) - for other settings see the documentation (link above) code // code for playing a sound stopAllSounds;

if (this._parent.usingNarration) { //the name is quotation marks is the linkage name of the narration file startNewNarrationSound("S6f2.mp3"); //the setPauseAndSoundFinished settings here should be the same as the else //except the middle one must be true setPauseAndSoundFinished(false,**true**,true,"disablepause"); } else { setPauseAndSoundFinished(false,false,true,"ignore"); }

// **if this code is in globals frame 2 cut and move it to globals frame 1** right = defineNewSoundEffect("right");

function pingCorrect(doStopAllSounds:Boolean) { // call this function when a correct answer has been selected // - or positive feedback needed // only needs to be defined once per scene if (doStopAllSounds == undefined) { doStopAllSounds = true; }   if (doStopAllSounds){ stopAllSounds; }   right.startSoundEffect(0,0,**false,10**); }

code

Check any other code frames that might involve sound - especially the second last frame on the globals & sound layer. code format="actionscript" // If you wish timeline to stop now, no matter what, use code below stop;

if (this._parent.usingNarration && !isSoundComplete) { showcontinue(false);// don't kill the pause setPauseAndSoundFinished(false,true,true,"disablepause"); } else { showcontinue;// will kill the pause } code 9) Test the movie (CTRL-Enter). Older activities may have compile errors. You may need to close the testing window, press CTRL-F, and search for:
 * 1) include "lib/actions/activities_01.as" --- replace all with --- #include "../classes/edu/clips/actions/activities_01.as"
 * 2) include "lib/actions/wrapperCommon.as" --- replace all with --- #include "../class/edu/clips/actions/wrapperCommon.as"

10) Continually press pause and play to see that the behaviour is correct.

11) If there are the narration and ensure that the showing of the continue button does not gray out the pause/play button before sound is finished; if it does change the call to showcontinue(false);

12) Once all the sound and animation is over the pause/play button should be disabled.

13) If the pings are too loud or too soft, check the definition of function pingCorrect (see code above) and change the 10 to a more suitable value.

Older Notes that may be useful
//NOTE: Double click on the sound object in the library to open up its properties. Double check the export setting to see if Flash is using the imported MP3 quality. If the compression is set to default change it to MP3 and then adjust the bit rate (48 kbps works well) and quality. While running your swf, if you encounter a "tinny" sound this will be due to the fact that Flash is ignoring the imported MP3 quality and you will have to manually adjust as above.**//

NOTE ABOUT SWAPPING FLA files: When audio files are imported into the Library of an FLA, they still have as part of their properties the pathname to their source files. If an FLA is moved around outside of the Flash program, then re-opened up – if Flash cannot find the source audio, it may become unstable. (This happened when trying to use an FLA that had the audio clips imported (and “linkaged”) in its Library, then the FLA was transferred onto another laptop- which had the Audio folder in a different spot.

FIX: The path is relative, not absolute, so it is possible to trick Flash into thinking things are fine by duplicating the Audio folder in the directory it was looking. Once you get the FLA working fine, saving it to a different directory isn’t an issue – when that happens, and you are INSIDE the Flash progam, the program automatically updates the file / folder connections and paths.

code format="actionscript" if (_parent.mySound.position < _parent.mySound.duration) { stop; soundonlypause; } code code format="actionscript" ////soundfinishedshowcontinue) stop; soundonlypause;////// code
 * where you want the timeline to STOP, pause and wait for the audio to catch up, then keep going add the following four lines of code in a keyframe: (This assumes that once the audio is done, the timeline should resume automatically  in the start frame you had selected soundfinishedplay)
 * IF the the audio is SHORTER than the timeframe, the stop; is not necessary (and will in fact mess up the clip) unless it is enclosed in the above IF statement (to check for the sound being finished).
 * IF you want the timeline to STOP no matter what, finish the audio, then show the Continue button, use the above code without the IF in the start frame you had selected

code format="actionscript" //////stop; soundonlypause; showcontinue;////// code
 * //where you want the timeline to STOP and SHOW CONTINUE button right away, pause and wait for the the button to be clicked, add the following lines of code in a keyframe://