PDA

Click to See Complete Forum and Search --> : loading XML data into a movie clip



valkyry
06-11-2001, 03:09 PM
hi.

I've been trying to load xml data into a movie clip that's 4 levels into the main timeline, and it's not working....

I copied the code in another file, making it the main timeline, and it works fine.

I'm assuming that xml only loads into the main timeframe, and that's the problem, but I'm not sure....

Any help would be greatly appreciated.

Thanks in advance.

VAYKENT
06-11-2001, 06:46 PM
When you load an xml doc you load it into an xml obj... if you've got something 4 levels deep or whatever, just create a new xml obj inside your 4 levels deep thing, and set it equal to the xml obj on the root.. that's a real easy way to do it..... I don't see why you have to do that... not that you don't have to, but whatever.... have fun!

Shad0w
06-13-2001, 11:25 AM
I came to this board just now looking for an answer to the exact same thing.

I think you're right, it must load the xml into the root, even if you have the load function inside another movieclip.

Strange (and very annoying) how you cant specify a target as with the loadvariables (from text file or CGI) command. Is this an oversight or is there a reason you can't load XML data into a target?

Cheers lads.

VAYKENT
06-13-2001, 01:04 PM
Just exactly how are you guys doing this... I haven't had any problem.... you create the XML object, and use the nameOfXMLObject.load(URL) method to place the xml document inside the xml object you created..... XML objects are scoped exactly like functions.... when they are declared... maybe you're declaring the new XML object in a different place??? I'm surprised you can't 'use' it the way you're wanting to.....

Shad0w
06-14-2001, 04:29 AM
Just to demonstrate what I mean, I have this code on the root timeline of a movie loaded into level2,

------------------------------------------------------------

menuXML = new XML();
menuXML.onLoad = parseXML;
status = "Loading data...";
menuXML.load("xmlmenu.xml");

function parseXML () {
if (this.loaded) {
status = "Data loaded.";
}
}

------------------------------------------------------------

However the dynamic text box 'status' never changes to 'Data loaded' which means the 'parseXML' function is never called because the xmldata is not loaded into the object 'menuXML'.

It is instead loaded into _level0.menuXML. What I don't understand is this, why is the data not loaded into the _level2.menuXML object?

Cheers.

VAYKENT
06-14-2001, 08:38 AM
Like I said, I don't know what you guys are smokin'... I got it to work the way it should.... BUT - I did change a couple of things...

Here's the movie explorer contents:

Scene 1
(text box for var _root.lStatus...), (_root.lStatus)
m_poo, (poo) // holds m_xml
(t b for var _root.rootData...), (_root.rootData)
(t b for var _root.targetedData...), (_root.targetedData)
b_findBoth
actions for b_findBoth
on (release) {
// sets text boxes on _root equal to targeted xml objects both embedded and not...
trace ("Finding...");
// Notice this one is grabbing from _root...
_root.rootData = _root.menuXML.toString();
// Notice this one is grabbing down inside...
_root.targetedData = _root.poo.xml.menuXML.toString();
}

Symbol Definition(s)
m_poo
m_xml, (xml)
b_load
actions for b_load
on (release) {
// These actions call the xml obj that's enbedded, and use it's load method to.. well... load :)
trace ("Loading...");
xml.menuXML.load("test.xml");
}
b_findBoth
m_xml
actions for frame 1
// This section sets up the new xml obj
menuXML = new XML();
// Here we set up the onLoad handler function
menuXML.onLoad = parseXML;
_root.lStatus = "Loading data...";
// Notice the slight change... we set the variable that will hold our 'loaded-or-not' Boolean status...
function parseXML (loadStatus) {
if (loadStatus) {
_root.lStatus = "Data loaded.";
} else{
_root.lStatus = "Data NOT loaded.";
}
}
b_load

So you can see that after loading the xml data inside '_root.poo.xml.menuXML' you can only pull it out with that same reference... you can not get the xml data from a reference to the root (i.e. - '_root.menuML'...)

I hope that's what you guys were looking for... unless... now that I think of it... if you were duplicatingMovieClip with something like this I wonder if it'd work.. it should still work...