101 posts
  • Elite Author
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
PixelBook says

Hi there,

I know this is a silly question but I don’t know the answer. How can I load a text from an external XML file into the flash project? I need this text to be parsed as HTML , so in my XML i have something like this:

<!CDATA[ ........some HTML code…..... ]]>

Thanks in advance

4128 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says
Hi there,

I know this is a silly question but I don’t know the answer. How can I load a text from an external XML file into the flash project? I need this text to be parsed as HTML , so in my XML i have something like this:

<!CDATA[ ........some HTML code…..... ]]>

Thanks in advance

Try this http://tinyurl.com/2u4xa6l

1612 posts
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says

Paul, there’s no need for you to be sarcastic, the guy was asking for help, and I intend to point him into the right direction :)

Assuming your XML file, named “your_xml.xml” looks like this
<main_node>
    <cdata_node>
        <![CDATA[Your <font color="#ff0000">HTML</font> code here.]]>
    </cdata_node>
</main_node>

paste the code below on frame 1 of your FLA file ( AS3 only!!!)

var xmlLdr:URLLoader = new URLLoader();
var xmlUrl:URLRequest = new URLRequest("your_xml.xml");
xmlLdr.load(xmlUrl);
xmlLdr.addEventListener(Event.COMPLETE, onXMLLoaded);

function onXMLLoaded(e:Event):void
{
    xmlLdr.removeEventListener(Event.COMPLETE, onXMLLoaded);//remove the XML loader event listener once the XML file is loaded
    var xmlData:XML = new XML(e.target.data);//assign the data taken from the XML file to a new XML object
    trace(xmlData);//traces all your XML file content
    trace("================================================");//separate the previous and the next output code
    trace(xmlData.cdataNode.toString());//traces precisely the HTML string that you need
}

Hope this helps!

If you really, really wanna learn, read more about XML here.

Regards,
Dani

4128 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says

No sarcasms intended Dani. His information was to vague for me to help him. I didn’t know what he needs it for, XML AS2 / XML AS3 , image loader? text loader? boolean functions, strings, numbers, arrays… So my link offered everything. Flash XML :) Includes everything… understand why I did it now ?

1612 posts
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says
[...] How can I load a text from an external XML file into the flash project? I need this text to be parsed as HTML [...]

I guess that pretty much explains what he needs to achieve, doesn’t it? :)

1612 posts
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says

I wasn’t offering him a complete, out-of-the-box, solution to his problem, I was merely pointing him into the right direction, or at least I hope so :)

101 posts
  • Elite Author
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
PixelBook says

thank you very much guys

1612 posts
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says
thank you very much guys

You’re most welcome, please let us know which solution helped you out :)

4128 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says
thank you very much guys

Sorry if I sounded sarcastic. Just pointing you out in thr right direction. I learned how to use XML via googling the exact same thing i gave you in my first post:-)

1612 posts
  • Author had a Free File of the Month
  • Microlancer Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says
thank you very much guys
Sorry if I sounded sarcastic. Just pointing you out in thr right direction. I learned how to use XML via googling the exact same thing i gave you in my first post:-)

@ cristy4s
Follow Paul’s (Enabled) advice, Google is your best friend when you really know what to look for :)

If you wanna push your Actionscript knowledge boundaries further, start with Lee Brimelow’s video tutorials.

Here are a couple of links you might be interested in:

http://gotoandlearn.com/play.php?id=64 (ActionScript 3 XML Basics)
http://gotoandlearn.com/play.php?id=65 (ActionScript 3 Advanced XML )

There is also a tutorial over there about basic XML and Actionscript 2, although I really hope you stick with AS3 , as it’s way more powerful and nice, and coding in AS3 is far more clean and well-structured than AS2 coding :)

Hope this helps! :)

by
by
by
by
by
by