Skip to main content
Inspiring
March 9, 2015
解決済み

text fields in array

  • March 9, 2015
  • 返信数 1.
  • 1077 ビュー

i m trying to make a hangman style game.i have 33 dynamic text fields on my stage like this.

i have parsed all text fields row by row into 3 arrays.

i also parsed my 3 words into 3 arrays with split method so i can check later if the letter that the user picked exists.

in next frame when the game begins and the user picks a letter although i can check if the letter exist in my first word array i cant display it on current textfield on my stage.

i get the following error:ReferenceError: Error #1056: Cannot create property text on String.

i guess when i parsed the textfields in arrays they automatically got strings.And i cant do this for example:

firstwordarray is the array where i parsed my first word with split method.

letterchosentxt is the textfield where the user picks a letter.

firstarray is the array where i parsed the first row(11) of text fields.

for(var p:uint=0;p<firstwordarray.length;p++)

  {

       if(letterchosentxt.text==firstwordarray

)

       {

            firstarray

.text=letterchosentxt.text;

            break;

       }

  }

thanks in advance.

このトピックへの返信は締め切られました。
解決に役立った回答 moccamaximum

I will try it and I will tell you.if I assign the text fields one by one into an array is wrong? Like this:

first array[0]=letter1txt.text;


yes, because you are not assigning the textfields but only their text property (these are two different things)

however you could put a textfield named "textfield1" into an array

either with:

array.push(textfield1)

or with

array[0] = textfield1

its important to mention that putting a displayobject into an array doesn`t do anything visibly to the displayobject but only provides a method to easily reference it.

返信数 1

Inspiring
March 9, 2015

just write

  firstarray

=letterchosentxt.text;

lockgun作成者
Inspiring
March 9, 2015

I have done it..if I trace it is there but it doesn't display on screen.

Inspiring
March 9, 2015

Make sure that you embed whatever font you are using in your dynamic textfields and that you use a small enough font that it will actually show something.