0 Replies Latest reply on Jul 7, 2007 10:10 AM by Newsgroup_User

    Styling text from an xml document

    Level 7
      I am bringing in content from an xml document to display in a text
      scroller. I have it all working, but there are some display issues that
      I need to figure out. Right now it looks all unformated, except for the
      font, text size and color, which are set by the dynamic text field. What
      I want to add is a way to set line breaks, bold headers of a different
      color and take out the commas in the text, which are from the array,
      that I am using to bring in the content from the xml document.

      I am bringing my content in like this:

      var aInfoText:Array = new Array;
      this.scroller_all.scroller_slider.infoScroll.textbox.autoSize = true;

      var xmlContent:XML = new XML();
      xmlContent.ignoreWhite = true;
      xmlContent.onLoad = function(bSuccess:Boolean):Void {
      if(bSuccess){
      trace("Loaded the xml successfully");

      var xnRoot = this.firstChild;
      var xnInfo = xnRoot.childNodes[0];

      for(var i:Number = 0; i < xnInfo.childNodes.length; i++){
      aInfoText.push(xnInfo.childNodes .firstChild.nodeValue);

      if(i == xnInfo.childNodes.length - 1){
      scroller_all.scroller_slider.infoScroll.textbox.htmlText = aInfoText;
      }
      }
      }
      };
      xmlContent.load("about.xml");

      The content in the XML document looks like this:

      <the_content>
      <info_text>
      <section_header>INFO</section_header>

      <headline>Some headline</headline>
      <bodycopy>Some content</bodycopy>

      <headline>Some headline</headline>
      <bodycopy>Some content</bodycopy>
      </info_text>
      </the_content>


      The issues that I have are the following:

      1) The text field/scroller displays the comma between all the childNodes.

      2) I set up the xml document the way I did, because I would like to
      apply certain styling to for example section_header or headline, as well
      as a line break and space after. I was thinking, that I could do that
      with css in Flash. I was hoping I could write a class for section_header
      and it would apply that styling to all of them. Is that possible, or is
      that something I can only do in html?

      3) Lastly, I would like to be able to have links in the text coming in
      from the xml document. I thought since this was set to htmltext, I could
      just add a <a href tag to the content in the xml, but that did not seem
      to work. What would be the best way to add links into the content?

      I know this is a lot of questions, but I would really appreciate any
      feedback on any of this. Thanks a lot for the help!!!