then in first step check out for: input text addEventListener KeyboardEvent.KEY_DOWN
second step: as3 load image
I'll provide you some sample code with the input text part, the image part you do the research for it.
Assuming you have an input text on the stage, with the instance name inputText :
inputText.addEventListener(KeyboardEvent.KEY_DOWN,inputText_onKeyDown);
function onKeyDown(evt:KeyboardEvent){
// if the key is ENTER
if(evt.charCode == 13)
{
// your code here
ProcessWord(inputText.text);
}
}
function ProcessWord(word:String)
{
word = word.toLowerCase();
switch (word)
{
case "new york": LoadSomeImage("images/newyork.jpg"); break;
case "london": LoadSomeImage("images/london.jpg"); break;
}
}
function LoadSomeImage(imagePath:String)
{
trace("loading image:" + imagePath);
// here you do the image load
}
- inputText.addEventListener(KeyboardEvent.KEY_DOWN,inputText_onKeyDown);
- function onKeyDown(evt:KeyboardEvent){
- // if the key is ENTER
- if(evt.charCode == 13)
- {
- // your code here
- ProcessWord(inputText.text);
- }
- }
- function ProcessWord(word:String)
- {
- word = word.toLowerCase();
- switch (word)
- {
- case "new york": LoadSomeImage("images/newyork.jpg"); break;
- case "london": LoadSomeImage("images/london.jpg"); break;
- }
- }
- function LoadSomeImage(imagePath:String)
- {
- trace("loading image:" + imagePath);
- // here you do the image load
- }
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”