The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 9 of 9

Thread: change font color in XML without CDATA

  1. #1
    5
    posts
    Registered User

    change font color in XML without CDATA

    Hello,
    I know that you can format text in XML through CDATA and htmlText option in flash.. my question is if one can format the content of an attribute in the same way.. i.e:

    If I have the following line in my XML file:
    <main Name="Hello World" Link="home.swf"/>

    is it possible to format the "Hello World" text? Can I for example put the CDATA option in the content of the "Name" -tag like so:

    <main Name="<![CDATA[<font color="#00FFFF">Hello World</font>]]" Link="home.swf"/>

    I've heard that one can do like this though:
    <main Name="&lt;font color='#0F0F0F'&gt;Hello World&lt;/font&gt;" Link="home.swf"/>

    But no success.. my question is if it's even possible, and if so how?

    Thank you in advance!

  2. #2
    you have your code in the Name attribute. You want it as a separate node
    <main> ---- in here ---- </main>

  3. #3
    5
    posts
    Registered User
    Exactly. So it's not possible to format the content in the attribute?


    Quote Originally Posted by senocular View Post
    you have your code in the Name attribute. You want it as a separate node
    <main> ---- in here ---- </main>

  4. #4
    Ah, I read this time and yes, that is what you asked for
    What you posted using &lt; and &gt; is correct.

  5. #5
    5
    posts
    Registered User
    Hehe cool! But still when I load the xml I see:

    <font color="#00FFFF">Hello World</font>

    it doesn't seem like it reads it as html... I tried adding the htmlText attribut to the textfield in flash without any success.

  6. #6
    how are you accessing it?

  7. #7
    5
    posts
    Registered User
    I load the XML file and access the attribute value like this:

    this.bttn.text_mc.texttween_mc.bttnName.htmlText = xmlNode.childNodes[1].childNodes[i].attributes.Name;

    This is set in a for-loop to access several nodes.

  8. #8
    hmm. I'm not sure what's going on. I did a quick test and it seems to work for me
    Code:
    var xml:XML = new XML('<main Name="&lt;font color=\'#00FFFF\'&gt;Hello World&lt;/font&gt;" Link="home.swf"/>');
    createTextField("output", 1, 0, 0, 100, 100);
    output.htmlText = xml.firstChild.attributes.Name;

  9. #9
    5
    posts
    Registered User
    I started messing around and found the problem.. of course with your previous input as a guide In addition to the code I simply selected the textfield and chose "render as html text" in the menu and it worked.

    Thank you very much for your assistance!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012