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

Convert AS3 'setTextFormat' to Javascript.

Participant ,
Apr 26, 2019 Apr 26, 2019

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");

442
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

LEGEND , Apr 26, 2019 Apr 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.

Translate
LEGEND ,
Apr 26, 2019 Apr 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

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
Participant ,
Apr 26, 2019 Apr 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?

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
LEGEND ,
Apr 26, 2019 Apr 26, 2019
LATEST

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.

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