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

The label component

Community Beginner ,
Jul 19, 2017 Jul 19, 2017

Hello, I have two questions that I really want to know how to do.

1. I have always wanted to change the color of the text that appears on the label. The problem is I don't know how to do it.

2. Whenever I put a long statement for it to appear on my label, it gets cut off. I know that you have to adjust the width and height of the label in order for it to fit. However, I want the text to go to the next line rather than the text being in one long line.

Please let me know.

TOPICS
ActionScript
354
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
Community Expert ,
Jul 19, 2017 Jul 19, 2017

here's info on customizing components Components Learning Guide for Flash: Examining ActionScript 3 components | Adobe Developer Connectio..., but why bother doing that with the label component?

it would be much easier to use a textfield or a movieclip that contains a textfield especially if you want to customize it.

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
Community Beginner ,
Jul 21, 2017 Jul 21, 2017

Thanks for the the link, Kglad.

I totally agree with you, textfield would be much easier. In the case where if I am making a program where a user press a button and gets a result, a label would be necessary in that situation. The reason why I wanted to change the color that appears on the label is to just put emphasis, indicating the answer. It is not that a big deal, it is just a curiosity of mine. As for the text going in the next line would be the necessity that I would like to know. I do not want a statement that is cut off because it is too long, it would be great if the text would go to the next line in order to see the full statement rather than keep adjusting the label to fit in one long line of text.

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
Community Expert ,
Jul 21, 2017 Jul 21, 2017

a label component is never necessary.  i can't think of anything a lable component does that cannot be easily duplicated with a movieclip, textfield and actionscript.

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 ,
Jul 19, 2017 Jul 19, 2017

Give this a try. Put a label component on the stage, give it a name of 'alabel'. Then try this script:

var l:* = alabel;

l.htmlText = '<P ALIGN="LEFT"><FONT FACE="Times Roman" SIZE="12" COLOR="#FF0000" LETTERSPACING="0" KERNING="0">Red Label</FONT></P>';

You will get red text.

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 ,
Jul 19, 2017 Jul 19, 2017

Part two. Make the label be a bit taller, and try this script:

var l:* = alabel;

l.htmlText = '<P ALIGN="LEFT"><FONT FACE="Times Roman" SIZE="12" COLOR="#FF0000" LETTERSPACING="0" KERNING="0">Red\nLabel</FONT></P>';

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
Community Beginner ,
Jul 21, 2017 Jul 21, 2017

Hello Colin,

I have tried the script you have provided me and I really appreciate it. However, I got a syntax error saying "A string literal must be terminated before the line break." The error highlights at the l.htmlText section.

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 ,
Jul 21, 2017 Jul 21, 2017
LATEST

You would have needed to select the label on the stage and in Properties give it a name of 'label' (no quotes) for my example code to work.

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