Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

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