This content has been marked as final.
Show 3 replies
-
1. Re: XML Loading
Newsgroup_User Oct 24, 2007 6:27 AM (in response to phejDC)phejDC,
> Can anyone tell me how to edit the AS attached to pull the
> xml from /Documents/includes/XML/? I would greatly
> appriciate it.
Sure thing.
This if() statement handles the loading.
if (_parent.xml_file == undefined) {
my_xml.load((String(_url.slice(0, (_url.length-3))))+"xml");
} else {
my_xml.load(img/_parent.xml_file);
}
It does the following: If a variable named xml_file is not present
(that is, has an undefined value) in the parent movie clip, the XML instance
named my_xml is instructed to load an XML file by the same name as the url
(the MovieClip._url property) if the SWF. The expression for that -- the
expression that returns the name of the SWF, but with an .xml extension --
is this:
(String(_url.slice(0, (_url.length-3))))+"xml"
... so you may precede that with your path:
"/Documents/includes/XML/" + (String(_url.slice(0, (_url.length-3))))+"xml"
The other half of that if() statement, the else clause, handles cases in
which the xml_file variable *is* present. In that case, my_xml is
instructed to load the XML file specified -- from this location:
img/_parent.xml_file
... so you could replace "img" with your own path:
"/Documents/includes/XML/" + _parent.xml_file
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."
-
2. Re: XML Loading
phejDC Oct 24, 2007 7:13 AM (in response to Newsgroup_User)Thanks Dave!
Just to be sure (I'm still trying to learn AS), that new code would look like this, correct? I'm at work so I can't see if that works, but I'll try it home this evening.
Thanks again! -
3. Re: XML Loading
Newsgroup_User Oct 24, 2007 7:43 AM (in response to Newsgroup_User)phejDC,
> Just to be sure (I'm still trying to learn AS), that new code would
> look like this, correct?
That should do it. That would precede the file's name with the path you
need. To test some of this stuff, I recommend the trace() function, which
puts values into the Output panel so you can see what's going on under the
hood ...
if (_parent.xml_file == undefined) {
my_xml.load("/Documents/includes/XML/" + (String(_url.slice(0,
(_url.length-3))))+"xml");
trace("/Documents/includes/XML/" + (String(_url.slice(0,
(_url.length-3))))+"xml");
} else {
...
You can read more about trace() and other debugging techniques for
ActionScript 2.0 in this article I wrote for the Adobe Dev Center:
http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html
David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."

