Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Displaying text from Combobox as typing?

Guest
Oct 13, 2013 Oct 13, 2013

Hi

I am making a standalone text field display the full word as the user types, but the word has to be from the choices in a ComboBox.

So as they type "a", if the first choice in the ComboBox is "apple", apple is displayed in the text box. Then they type "aw", then if "aware" is the first "aw' word in the combobox, aware is displayed etc

I'm about 1/3 the way through coding it, and thought I'd ask here is there is a standard way of doing this?

TOPICS
ActionScript
698
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Oct 14, 2013 Oct 14, 2013

//for simplicity`s sake I use strings, if you have a Combo´Box with a DataProvider simply use that instead

var strings:Array = ["america","australia","alligator","anchorman"];

strings.sort();

tf.addEventListener(Event.CHANGE, autocomplete);

function autocomplete(e:Event):void

{

    var input:Array = e.target.text.split("");

    for (var i:uint = 0; i<input.length; i++)

    {

        for (var j:uint = 0; j<strings.length; j++)

        {

            for (var k:uint = 0; k<strings.length; k++)

            {

   

...
Translate
Guru ,
Oct 14, 2013 Oct 14, 2013

//for simplicity`s sake I use strings, if you have a Combo´Box with a DataProvider simply use that instead

var strings:Array = ["america","australia","alligator","anchorman"];

strings.sort();

tf.addEventListener(Event.CHANGE, autocomplete);

function autocomplete(e:Event):void

{

    var input:Array = e.target.text.split("");

    for (var i:uint = 0; i<input.length; i++)

    {

        for (var j:uint = 0; j<strings.length; j++)

        {

            for (var k:uint = 0; k<strings.length; k++)

            {

                var arrstrings:Array = strings.split("");

                if (input == arrstrings)

                {

                    e.target.text = strings;

                    e.target.setSelection(0,e.target.text.length);

                    return;

                }

                else

                {

                    e.target.text = "NO MATCH FOUND";

                    e.target.setSelection(0,e.target.text.length);

                }

            }

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 17, 2013 Oct 17, 2013
LATEST

Thanks Mocca. This was the pefect framework to get me going.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines