Skip to main content
Known Participant
May 13, 2011
Answered

style htmlText in as3?

  • May 13, 2011
  • 3 replies
  • 1045 views

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.

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

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

3 replies

JimondoAuthor
Known Participant
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

Kenneth KawamotoCommunity ExpertCorrect answer
Community Expert
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

JimondoAuthor
Known Participant
May 13, 2011

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

relaxatraja
Inspiring
May 13, 2011

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

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

JimondoAuthor
Known Participant
May 13, 2011

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/