Sunday, June 17, 2007

The action script

Here is a sample of the ActionScript which drives the Flash animation. Its not finalised yet and will be fine tune once the hardware has been installed.


var snd = new Sound();
snd.attachSound("mysound");

mouse.hide();
stop();

------------------------------------------------

onClipEvent (load) {
mouse.hide();
stop();
}


on (release) {

_root.snd.start(0, 10); // Play sound

if (_this._currentframe > (_this._totalframes-1)) {
gotoAndStop(_totalframes-1)
stop();
}
else
{

// _root.snd.start(0, 10); // Play sound
//_root.snd.setVolume(25);

rewind = false;
foward = true;
play();
}
}

on (press)
{
//_root.snd.stop(); // Stop sound effect

stop();
rewind = true;
reduce = 0;
}

onClipEvent (enterFrame) {
if (framecount > 300) // Changed this
{
framecount = 0;
forward = false;
}

x = (this._currentframe / 4)

if ((forward == true) && (framecount < 300 - x))
{

_root.snd.setVolume(volumeValue); // Fade Sound In
_root.snd.start(0, 10); // Play sound

if (volumeValue < 25){ // Fade Counter
volumeValue++;
}

nextFrame(); // Move to next frame
framecount++;

}

if (rewind==true){

volumeValue = (25 - reduce); // Fade Out Volume
_root.snd.setVolume(volumeValue); // Change Volume
_root.snd.start(0, 10); // Play sound

if (reduce < 25){ // Fade Counter
reduce++;
reduce++;
}

y = (this._currentframe / 100)

if (_currentframe > 0){


gotoAndPlay(this._currentframe - 4);
// prevFrame();
}
}
}




on (keyPress "") {
mouse.hide();
}

No comments: