Click to See Complete Forum and Search --> : Displaying XML into Flash--

04-18-2001, 08:11 AM
I am new to xml and I would like to change my current blog reader on my site from loading html to loading xml. How would I go about doing this? I know I need to do this:
//load the xml,
//parse the xml, and
//create a new object
Here is my xml structure

<*time>Time Of Post<*/time>
<*text>News text<*/text>
<*links>Featured Links<*/links>
<*author>Person Posted<*/author>

my xml file:
my not working swf file:
I did try downloading some of the xml movies flashkit has, and understood very little on how to do this..
Any help or ideas on how to do this would be great.


[Edited by diavolo on 04-18-2001 at 08:15 AM]

04-18-2001, 08:27 AM
It would be better if it loaded html, loading variables is alot faster than parsing xml files.

I started by blog off with parsing xml and decided to change to loading html into a html enabled textfield!

04-18-2001, 08:46 PM
good, that's the way mine is right now. I just want to learn more on how to import and xml file in flash. For instance, how would I just add xml text to flash? Thanks for your help Guy!


04-19-2001, 05:28 AM

well, it might be easier for you to read the help section on the XML object, but basically you do this:

- create a new XML object
var myXMLDoc = new XML();

- add an 'onload' event handler to your object
(this is the name of the function to call when the file has loaded)
myXMLDoc.onload = myOnloadFunction;

- load your XML file into the object

once the file has loaded, the function myOnloadFunction is automatically called. use this function to either parse the XML document or to go to a part in the flash movie that handles this job.

I found that the easiest way is to include all the data as XML tag attributes rather than as text like you did, so you do:

<BLOGItem date="19th April 2001">
<LINK url="http:// 1" descr="this and that"/>
<LINK url="http:// 2" descr="this and that"/>
<LINK url="http:// 3" descr="this and that"/>

( the /> at the end are automatic closing statements, you can also write <LINK ...></LINK> )

****, this is getting long!
anyway, have a look in the help sections under XML.attributes and XML.hasChildNodes and XML.childNodes etc. etc. and just experiment - that's what I did....

[I don't know anything about XML, maybe it's all wrong...]

04-19-2001, 05:29 AM
yeah - so, I'm a bit thick and didn't realise I had to format that bit as code....

how's that go?

04-19-2001, 05:52 AM
f*ck - and it should have been

onLoad (with capital L) instead of onload...

this is getting worse and worse :)

04-19-2001, 08:51 AM
haha thanks man--this will help a great deal.:)


04-19-2001, 12:59 PM
So will loading and parsing the XML work on the WEB?? I can't figure that out as of yet. I have a perfect XML newsfeed configured, but it will just NOT work on the web, only locally. Let me know if anyone has accomplished, because I've had no luck :(
[Edited by Mistaderelict on 04-19-2001 at 10:13 PM]

04-19-2001, 07:59 PM

Great post... xml was the last bit of flash trickery I have been putting off... as (my) luck would have I was asked to create some flash content that involves xml data (sure I can do that, I said "translation: if I say no then he'll think I am a wieny") ...anyways you probably saved me an hour or two of research... so thanks..

04-20-2001, 01:48 AM
I found the XML parsing to be a bit slippery. I have noticed that there are a lot of null nodes and silly things like myXML.firstChild.nextSibling.firstChild to be awkward as hell and inconsistent in the manner in which it seems to walk the nodes. For instance, if I take two steps forward and two steps backward in the XML, I *can* land up in a spot in the node structure that is not the same one I started that short little trip on. I believe this to be a flaw based on the timing of processing clicks.. like there is some mysterious invisible wait state in the low-level mouse routines... anyway

So what I did was basically do, is what almost everyone recomends. I place the nodes into an array just recently, and array that holds object that mimic the structure of the XML. here is some code fragments to illustrate what I mean.

quoteXML = new XML();
currentquote = new XML();
quoteXML.onload = setupXML;
childrenArray = new Array();
CQ = new Array();
QuoteObject = new Object();
QuoteArray = new Array();
Qindx = 0;

// constructor function
function Quote () {
//..blah blah
// set the qsymbol text control to the value in the array.
function DisplayQuote() {
qsymbol = _level0.QuoteArray[_level0.Qindx].symbol;
//..blah blah

function AssembleQuoteArray () {
theseChildren = currentquote.childNodes;
CQ = theseChildren; // auto array construction :)
for (i=0; i<theseChildren.length; i++) {
if (CQ[i].attributes.name == "Symbol") {
QuoteArray.push(new Quote);
_level0.QuoteArray[_level0.Qindx].symbol = _
qsymbol = CQ[i].attributes.value;
.. you get the idea even though my code looks atrocious on this display.

Hope that helps at least one poor bastard like me :)