I’m having trouble with the code to match a key press and what’s in an MC.
The MC is called letter and the text box in it is called txt. When it appears on the screen I want the user to press the key of the letter in the box, but I am having issues.
ActionScript Code:
[FONT=Courier New][LEFT]</p>
<p>var myLetter = letter.[COLOR=#000080]txt[/COLOR].[COLOR=#0000ff]text[/COLOR];</p>
<p> </p>
<p>this.[COLOR=#0000ff]onKeyDown[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR]</p>
<p>[COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] == [COLOR=#ff0000]“g”[/COLOR][COLOR=#000000])[/COLOR]</p>
<p> [COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]// = 71</p>[/COLOR]
<p> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]// = G</p>[/COLOR]
<p> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]// = G</p>[/COLOR]
<p> [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]myLetter == [COLOR=#0000ff]Key[/COLOR].[COLOR=#0000ff]getCode[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR][COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];[COLOR=#000000]}[/COLOR]</p>
<p> [COLOR=#000000]}[/COLOR] </p>
<p> </p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p>Key.[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];</p>
<p>
[/LEFT]
[/FONT]
Can someone see what I am doing wrong?