?
Solved

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

Posted on 2008-10-19
2
Medium Priority
?
1,329 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

743 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