|
Home / WizTextTyper / Tutorials / HOW-TO: Typing Sounds |
||||
|
|
About Tutorial |
This 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.
|
|||||
| Contact |
Email jonwiz at jonwiz dot com |
Phone
647-405-4070 |
Location Toronto, ON, CA |
||
Websites & Graphics |
by Jonathan Wiznuk |
© 2008 Jonwiz Media — All Rights Reserved. — VALID XHTML + CSS — View the Sitemap » |
|||