Solved

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

Posted on 2008-10-19
2
1,319 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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 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…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

717 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