# Array into an input text field

**URL:** <https://forum.kirupa.com/t/array-into-an-input-text-field/317311>\
**Category:** flash\
**Created:** [December 16, 2010, 3:41pm UTC](https://forum.kirupa.com/t/array-into-an-input-text-field/317311 "2010-12-16T15:41:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![profZ](https://avatars.discourse-cdn.com/v4/letter/p/6f9a4e/32.png) [@profZ](https://forum.kirupa.com/u/profZ)\
**Post date:** [December 16, 2010, 3:41pm UTC](https://forum.kirupa.com/t/array-into-an-input-text-field/317311/1 "2010-12-16T15:41:24Z")

</div>

[COLOR=#333333][SIZE=3][FONT=Times New Roman]Greetings,[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]I am an educator and I am designing an interactive activity for my students. I created two buttons named baby\_B and baby\_G, and an input textfield named text\_entry. When a student presses baby\_B, the letter “B” is entered into the input text field; if a student presses baby\_G, the letter “G” is entered into the input text field.[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]For a student’s solution to the input text field to be correct, it has to contain values BBB, BBG, BGB, BGG, GGB, GBG, GBB, and GGG in any order. I created an array named solution\_S with these values. I also have an enter the solution button named enter\_btn. The student can check their solution by pressing the enter\_btn button; if the input textfield is correct, the quiz moves on to the next frame in my timeline; if it is incorrect, it moves to a different frame in my timeline. So far I have the following script:[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]stop();[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][FONT=Times New Roman][SIZE=3] [/SIZE][/FONT][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]baby\_B.addEventListener(MouseEvent.CLICK, letterB);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]function letterB(event:MouseEvent)[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] text\_entry.appendText(“B”);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][FONT=Times New Roman][SIZE=3] [/SIZE][/FONT][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]baby\_G.addEventListener(MouseEvent.CLICK, letterG);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]function letterG(event:MouseEvent)[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] text\_entry.appendText(“G”);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][FONT=Times New Roman][SIZE=3] [/SIZE][/FONT][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]enter\_btn.addEventListener(MouseEvent.CLICK, check);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]function check(event:MouseEvent):void {[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] var solution\_S:Array=[“BBB”,“BBG”,“BGB”,“BGG”,“GBB”,“GBG”,“GGB”,“GGG”];[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] [/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] if(solution\_S.indexOf(text\_entry.text)\>=0)[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] {[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] gotoAndStop(61);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] }[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]else[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]{[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman] gotoAndStop(62);[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE][/COLOR]  
[COLOR=#333333][FONT=Times New Roman][SIZE=3] [/SIZE][/FONT][/COLOR]  
[COLOR=#333333][SIZE=3][FONT=Times New Roman]The enter button works correctly when any single element of the array is entered into the input text. However, all of entries must be in the input text – but they can be in any order – for a solution to be correct. How can I do this? Thanks![/FONT][/SIZE][/COLOR]
