A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML DISTINGUISHING HEADINGS??

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    449
    .hi guys,
    I am loading an external XML file into a text box. It all works fine but comes in all the same colour/ same size, is it possible to make headings of the XML file in different colours like in HTML,
    .thanks,
    .tom

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Uhm...

    That might be a question for the Fonts forum...

    http://board.flashkit.com/board/foru...php?forumid=49

    ...but yes it is possible.

  3. #3
    New Title:
    Join Date
    Jul 2002
    Posts
    87
    You are probably going to have to fool around with the TextFormat object.

    Hmm, well here's some code:

    Code:
    var x = new XML();
    
    x.parseXML("<doc><h1>Heading1</h1><p>Paragraph</p><p>Another paragraph</p></doc>");
    
    tally = 0;
    currentY = 0;
    
    var n = x.firstChild.firstChild;
    var tf, size, c;
    
    while (n) {
      this.createTextField("text" + tally, tally, 0, currentY, 0, 20);
      var t = this["text" + tally];
      t.autoSize = true;
      tally++;
      tf = t.getTextFormat();
    
      if (n.nodeName == "h1") {
        tf.size = 20;
        tf.color = 0xff0000;
      } else if (n.nodeName == "p") {
        tf.size = 12;
        tf.color = 0x000000;
      }
    
      t.text = n.firstChild.nodeValue;
      t.setTextFormat(tf);
      currentY += t._height;
    
      n = n.nextSibling;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center