0

I'm testing a couple of things in preparation for some localization changes. Right now I'm trying to change some default text formatting at run-time, and running into a problem: the text formatting reverts when I click into a textInput or textArea.

So I start off changing a textField's textFormat and defaultTextFormat like so:

import flash.text.TextFormat;

var textFormat:TextFormat;

textFormat = new TextFormat();

textFormat.font = "Palatino Linotype";
textFormat.size = 12;
textFormat.color = "0xFFFFFF";

function setFormatting():void
{
    characterNotes.textInput.textField.setTextFormat(textFormat);
    characterNotes.textInput.textField.defaultTextFormat = textFormat;
}

setFormatting();
characterNotes.textInput.text = "Test test test";

And if I don't click on anything, then the formatting is correct (i.e., Palatino, 12 point, white). But if I click on the textField in my characterNotes movie clip, it goes back to its original default text format (set in Adobe Animate's editor's component properties window). If I click in and out of the textField a couple times, it will keep the intended text format (set in code). Any idea why it reverts at all? How can I stop it from reverting?

Also, I already tried adding an addEventListener("focusIn", setFormatting) to the textField, but the format reverts anyway.

Nathaniel
  • 461
  • 1
  • 4
  • 16
  • I expect your stage or `characterNotes` to have more than a single frame, this way when either MC changes frame your textfield gets reinstated (aka destroyed then created anew). I don't trust visual editor with messing up *MY* code, thus I'd say you try creating a new `TextField` with code, place it somewhere and attach this text format, and check its behavior vs clicking and changing frames. – Vesper Oct 25 '19 at 04:45
  • have you embedded the font? – Patang Oct 25 '19 at 11:30
  • I'm doing this in a text document, just one frame in the stage and the ```characterNotes``` object. I can try creating a new one anyway though. And yep, all fonts involved are embedded. – Nathaniel Oct 25 '19 at 15:58

0 Answers0