Skip to main content
Inspiring
July 14, 2011
Answered

iOS text field problem.

  • July 14, 2011
  • 2 replies
  • 1230 views

I need the user to enter a word, so I added a simple text field to the stage.  However, it behaves strangely on the actual device (iPod Touch). Attached are two screenshots that show how the font size increases when the input is activated.  Has anybody seen this problem?

This topic has been closed for replies.
Correct answer sanika Kulshreshtha

Hi,

I believe you have specified a textFormat for the text. You need to add the following

// Assuming this is the format

var txtFormat:TextFormat = new TextFormat();

txtFormat.size = 20;

t1 = new TextField();

t1.defaultTextFormat = txtFormat;

// Apply the default text format that we just set to the text that's already in the text field ("g")

// Otherwise the default text format will only be applied to *new* text that's *typed* into the text field!

// Without this, the initial text in the text fields ("g") will use the default for a

// flash text field (Times New Roman 12pt), rather than the defaultTextFormat (Times New Roman 20pt).

t1.setTextFormat(t1.defaultTextFormat);

addChild(t1);

This sets all of the existing text in the text field to the specified format (making it the same as the default). Now when the text field is first rendered it uses the default format that you set, and when you type it also uses that same format, and so the format no longer appears to change.

Hope this helps.

Sanika

2 replies

sanika KulshreshthaCorrect answer
Participating Frequently
July 15, 2011

Hi,

I believe you have specified a textFormat for the text. You need to add the following

// Assuming this is the format

var txtFormat:TextFormat = new TextFormat();

txtFormat.size = 20;

t1 = new TextField();

t1.defaultTextFormat = txtFormat;

// Apply the default text format that we just set to the text that's already in the text field ("g")

// Otherwise the default text format will only be applied to *new* text that's *typed* into the text field!

// Without this, the initial text in the text fields ("g") will use the default for a

// flash text field (Times New Roman 12pt), rather than the defaultTextFormat (Times New Roman 20pt).

t1.setTextFormat(t1.defaultTextFormat);

addChild(t1);

This sets all of the existing text in the text field to the specified format (making it the same as the default). Now when the text field is first rendered it uses the default format that you set, and when you type it also uses that same format, and so the format no longer appears to change.

Hope this helps.

Sanika

Inspiring
July 15, 2011

Thanks!!

I got the same problem yesterday. This trick allowed me to solve it!

relaxatraja
Inspiring
July 15, 2011

Is a known problem, Give it a try with embedding fonts or either use _sans for the textfield and it will work.