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

style htmlText in as3?

New Here ,
May 12, 2011 May 12, 2011

Hi, I am looking for help and to be pointed to a good place to learn actionscript 3. I am new to flash and actionscript is proving to be very difficult to understand. I do not know the best method to do what i want or the order code needs to be in.  I have several buttons that when clicked show text in a dynamic text box. I want to style part of the text bold, some of it a different font size and change it's leading. I had help with the code i have already. So far the code works great and makes sense to me but I don't know where to go from here. I have spent over a week trying to figure this out- already checked the flash help files but need more step by step help i think. I've been told i should do a stylesheet but i have no idea how to do that either- like i said completely new to this. At this point i am so frustrated and would love to know the correct code to use. Here is everthing in my actions window:

var green_btnInfo = "I want this line to be bold and 14pt<br/>This line should also be bold and 14pt<br/>This line should be regular and 10pt and i want to control it's leading";

green_btn.addEventListener(MouseEvent.CLICK, showInfo);

function showInfo(evt:MouseEvent):void
{
    textBox.htmlText = this[evt.currentTarget.name + "Info"];
}

i did find this http://learnola.com/2008/12/03/actionscript-3-tutorial-using-html-and-css/ but it doesn't match anything i have so not sure what method to use.

TOPICS
ActionScript
1.1K
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

Community Expert , May 13, 2011 May 13, 2011

There are many ways to accomplish this but the easiest for you would be to change the text to:

var green_btnInfo = "<font size='14'><b>I want this line to be bold and 14pt</b></font><br/><font size='14'><b>This line should also be bold and 14pt</b></font><br/><font size='10'><textformat leading='-5'>This line should be regular and 10pt and i want to control it's leading</textformat></font>";

That's it

Translate
Mentor ,
May 12, 2011 May 12, 2011

http://www.republicofcode.com/tutorials/flash/css/

http://www.republicofcode.com/tutorials/flash/as3css/

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
New Here ,
May 13, 2011 May 13, 2011
LATEST

thanks very much for those links! i found a few other ones from there that are really helping to explain as3 for a newb such as myself

http://www.republicofcode.com/tutorials/flash/as3variables/

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 ,
May 13, 2011 May 13, 2011

There are many ways to accomplish this but the easiest for you would be to change the text to:

var green_btnInfo = "<font size='14'><b>I want this line to be bold and 14pt</b></font><br/><font size='14'><b>This line should also be bold and 14pt</b></font><br/><font size='10'><textformat leading='-5'>This line should be regular and 10pt and i want to control it's leading</textformat></font>";

That's 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
New Here ,
May 13, 2011 May 13, 2011

rest of styling worked but leading doesn't seem to be working for some reason

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
New Here ,
May 13, 2011 May 13, 2011

awesome, that worked- thank you guys so much! now i can actually make some progress on my work today. I'll be checking out those links too thanks

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