| Home Portfolio Wiz Text Typer Testimonials Faq Contact | |
|
|
Tutorial: Wiz Text Typer Typing SoundsThis tutorial explains how to use typing sounds when the letters are typed. In addition it will also show how to use sounds for spacebar and enter keys!
Put the following code on the _root timeilne.
//add sounds
typingSound = new Sound();
typingSound.attachSound("keypress");
spacebarSound = new Sound();
spacebarSound.attachSound("tick");
returnSound = new Sound();
returnSound.attachSound("return");
//define onTyping callback listener
_root.onTyping = function(finished, n, nTotal, curChar) {
typing = true;
if (curChar != " ") {
//dont make sounds while parsing tags
if (prevChar == "<") {
skipMode = true;
}
if (prevChar == ">" && curChar != "<") {
skipMode = false;
}
//make an ENTER key sound when it types a linebreak
if (prevChar == "<" && curChar == "b") {
returnSound.start(0, 0);
}
//only play while not in skipMode
if (!skipMode) {
//play the sound each time a letter is typed
_root.typingSound.start(0, 0);
}
} else {
//current character is a space
spacebarSound.start(0, 0);
}
prevChar = curChar;
};
//add the listener
myTyper.addListener(this);
myTyper.setSentence("type this sentence with keypress sound! wooohooooo!",true);
That's all folks! Now you've got a sweet typing sound like a futuristic spaceship console.
|
|
Toronto Website Development for small business — © 2010 Jonwiz Media — 647-405-4070 |