Skip navigation
John Delamotte
Currently Being Moderated

CSS tags

Jul 18, 2012 1:47 PM

I created a dymanic text field (already added to the stage) and made it html text. My problem is that I can't change some of the styles, such as p, span or b. I embeded the font  and need to create a h1 tag, which I was trying to do with classes. Could someone please help me and tell me what I'm doing wrong. Here is my code;

 

 

myTF.htmlText = "";

 

myTF.htmlText += "<span class='headings'>Treaty with the Blackfeet Sioux, 1865.</span>";

myTF.htmlText += "<p>I have some text in here</p>";

myTF.htmlText += "<p>I have some more text in here</p>";

myTF.htmlText += "<p>I now have some text and a<a href='event:link'>link</a> to another frame in here</p>";

myTF.htmlText += "<p>I now have some text and a<a href='http://www.google.com'>link</a> to a website in here</p>";

 

myTF.addEventListener(TextEvent.LINK, myTFF);

 

function myTFF(e:TextEvent):void

{

    gotoAndStop(e.text);

}

 

 

var myCSS:StyleSheet = new StyleSheet();

myCSS.setStyle("a:link", {color:'#0000CC',textDecoration:'none'}); <----Works

myCSS.setStyle("a:hover", {textDecoration:'underline'});  <----Works

myCSS.setStyle(".heading", {color:'#FFF'});    <-----Not working (with or without ".")

 

 

myTF.styleSheet = myCSS;

 
Replies
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 18, 2012 3:52 PM   in reply to John Delamotte

    heading != headings.

     

    fix one of those.

     

    and assign the styles before using the styles:

     

     

     

     

    var myCSS:StyleSheet = new StyleSheet();

    myCSS.setStyle("a:link", {color:'#0000CC',textDecoration:'none'}); <----Works

    myCSS.setStyle("a:hover", {textDecoration:'underline'});  <----Works

    myCSS.setStyle(".heading", {color:'#FFF'});    <-----Not working (with or without ".")

     

    myTF.styleSheet = myCSS;

     

    myTF.htmlText = "";

     

    myTF.htmlText += "<span class='heading'>Treaty with the Blackfeet Sioux, 1865.</span>";

    myTF.htmlText += "<p>I have some text in here</p>";

    myTF.htmlText += "<p>I have some more text in here</p>";

    myTF.htmlText += "<p>I now have some text and a<a href='event:link'>link</a> to another frame in here</p>";

    myTF.htmlText += "<p>I now have some text and a<a href='http://www.google.com'>link</a> to a website in here</p>";

     

    myTF.addEventListener(TextEvent.LINK, myTFF);

     

    function myTFF(e:TextEvent):void

    {

        gotoAndStop(e.text);

    }

     


     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 19, 2012 7:46 AM   in reply to John Delamotte

    you have a typo in your code.  you used heading and headings.  those are not the same.

     

    copy and paste the code i suggested.  if you don't see any change in your heading span, change the color in the css to make it obvious it's working.

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 19, 2012 9:18 AM   in reply to John Delamotte

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points