Skip to main content
PATurmel12
Inspiring
April 26, 2019
Answered

Convert AS3 'setTextFormat' to Javascript.

  • April 26, 2019
  • 1 reply
  • 500 views

In Actionscript 3 I could format the text of parts of a text field.

myTextField.setTextFormat(myTextFormat, 3, 6);

How can I do this with Javascript?

I am using jQuery:

$("#myTextField").css('font-size', "20px");

This topic has been closed for replies.
Correct answer ClayUUID

Then it's an HTML input textfield element, and you style it like any other HTML element, using CSS. Animate has no native functionality for this.

1 reply

Legend
April 26, 2019

Are you talking about a component textfield, or a native Animate textfield?

If it's an Animate textfield, in Canvas documents they only support a single text styling for the entire textfield. No mixed formatting. This is an intrinsic limitation of the HTML5 canvas text API (thanks Apple!). To change the properties of the textfield, just assign to the property you want to change, e.g.--

this.myTextField.color = "#FF0000";

https://www.createjs.com/docs/easeljs/classes/Text.html

PATurmel12
Inspiring
April 26, 2019

Thanks ClayUUID,

actually it's an input textfield using the component in Animate.

So it's not actually part of the canvas.

Does this make any difference?

ClayUUIDCorrect answer
Legend
April 26, 2019

Then it's an HTML input textfield element, and you style it like any other HTML element, using CSS. Animate has no native functionality for this.