Solved

AS3 - Can't get style sheet to actually format my text

Posted on 2008-10-19
2
1,314 Views
Last Modified: 2013-11-11
I've got an xml file that allows users of the application I'm creating to enter font/color/size info for a number of styles. I've also got an xmlLoader class that reads in the xml and creates the style sheet. Here's the function in the LoadXML.as class that creates the styles:

private function createTextStyles(_xml) {
                  trace("creating text styles");
                  //create text formats for all font defs
                  fontInfoList = _xml.meta_info.all_swfs.fontFormatInfo.fontFormat;
                  for (var i:int=0; i < fontInfoList.length(); i++)
                        {
                              var styleObj:Object = new Object();
                              trace("fontInfoList[i].font_size: " + fontInfoList[i].font_size);
                              styleObj.fontSize = fontInfoList[i].font_size;
                              trace("styleObj.fontSize: " + styleObj.fontSize);
                              styleObj.color = fontInfoList[i].font_color;
                              styleObj.fontFamily = fontInfoList[i].font_name;
                              var styleName = fontInfoList[i].@fieldType;
                              trace("styleName: " + styleName);
                              fontstyles.setStyle(styleName, styleObj);
                        }
            }
            public function get styleNames():Array
            {
                  return fontstyles.styleNames;
            }


Then in my .fla - I'm creating and text field and applying the appropriate style, as shown here:

function showEmployee(empNum) {
      //projectXML.formatEmployeeText(i);
      trace("calling emp info");
      var empInfo = projectXML.getEmployeeInfo(empNum);
      //projectXML.getEmployeeInfo(empNum);
      var tf:TextField = new TextField();
      tf.x = 25;
      tf.y = 25;
      tf.width = 500;
      tf.multiline = true;
      tf.wordWrap = true;
      tf.autoSize = TextFieldAutoSize.LEFT;
      tf.styleSheet = projectXML.getStyleSheet();
      tf.htmlText = "<span class='nameheading'>" + empInfo.empname + "</span>";
      addChild(tf);
      
}

The problem is that the style 'nameheading' is not applied. My text displays in tiny Times Roman. I'm sure I'm doing something simple incorrectly, but when I look at the documentation, I seem to be doing everything correctly. Can anyone point me to my error?
0
Comment
Question by:katyjack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 22756547
what format does your nameheading output in?

should be something along these lines?

  .nameheading {
      blah blah
   }
0
 

Author Closing Comment

by:katyjack
ID: 31507594
That was it - I didn't have the . in front of the name.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question