CodeFLV

Return to Code Snippets

=Code for playing an FLV in conjunction with narration=


 * Globals Frame 1**

code format="actionscript" continuebutton; //code for playing a sound //set the frame label with row number e.g. r01 stopAllSounds; this._parent.mySound = new Sound(this); this._parent.mySound.attachSound("sound1"); this._parent.mySound.start(0,0);
 * 1) include "lib/actions/activities_01.as"

soundonlypause; soundfinisheddisablepause; code


 * Actions Frame 2 (Frame 1 is empty)**

code format="actionscript" stop;

//set the path depending on whether the activity is in the wrapper or not linear.contentPath = _parent.activity_path+"CL002_C02_A01_M_Linear.flv";

//proceed to the next frame once the movie is ready linear.ready = function { linear.skin = _parent.activity_path +"ArcticExternalPlaySeekMute.swf"; play; };

//when the movie reaches the end, show the continue button linear.complete = function { showcontinue(false); }; code


 * Actions Frame 3**

code format="actionscript" //once the movie is ready, put it into the pause state at the beginning //the user must press the play control to make it start //note that the continue button will appear when the movie is complete

linear.pause; linear.playheadTime = 0; stop; var changed_state:Boolean = false;

onEnterFrame = function { if (linear.playing) { //The flv is playing, the sound should not be and the play/pause button is greyed this._parent.mySound.playing = false; this._parent.mySound.stop; _global.globalPause = "scenepause"; changed_state = true; } else if (changed_state) { //the flv is not playing after having been playing //give the play button back so that the narration can be resumed if (this._parent.mySound.position<this._parent.mySound.duration) { _global.globalPause = "soundonlyplay"; changed_state = false; }   } }; code