FINAL ECHO SOUND FX CODE
------------------------------------------
-
Hear it:
http://img318.images..image=audioas0sr.swf
What you must know before using this script:
- calling functions
- importing sounds into the library
- applying a linkage to sounds
How to use
This script contains comments helping you to tweak the effect to your needs. It works with virtually any sound. But to give a good advice, the effect will sound more realistic with a sound that has a sharp end (i.e. no fade out or silence).
The code
// IMPORTANT
// This code must be on a frame in order to make the code effective
_root.vol1 = 100;
_root.sound1 = new Sound();
// Replace "son1" with your linked sound ID (right-click on your sound in the library, choose "Linkage", then check "Export for ActionScript" and put a linkage name in the corresponding box)
_root.sound1.attachSound("son1");
_root.onEnterFrame=function(){
// Specify the type of activation event below (this example calls the function when you press the "Enter" button. But you can call the fonction "echo()" from any other method. If you use another method, please remove the 3 lines below
if (Key.isDown(Key.ENTER)) {
echo();
}
function echo() {
_root.sound1.stop();
_root.vol1 = 100;
_root.sound1.setVolume(100);
_root.sound1.start();
_root.sound1.onSoundComplete = function() {
_root.sound1.setVolume(_root.vol1);
// Replace NUMERICVALUE below to change the length of echoed sound from the end of your sound (in seconds, must be smaller than the total length of your sound)
_root.sound1.start(NUMERICVALUE);
// Replace NUMERICVALUE2 below to change the length of the fade out (smaller value means longer fade out)
_root.vol1 -= NUMERICVALUE2;
if (_root.vol1<0) {
_root.sound1.stop();
_root.sound1.setVolume(100);
_root.vol1 = 100;
}
}
}
}
Need help ?
Contact me via MSN, email or AIM (see in my profile).
~gorman2001