View Full Version : Can't open an XML file
javadi82
July 17th, 2003, 01:46 AM
There is an xml file named:"menu.xml". It's path is "C:\menu.xml".And its code is:
<menu>
<mainitem>
<item>Alphabet</item>
<subitem>A</subitem>
<subitem>B</subitem>
</mainitem>
</menu>
The actionscript written to open the file is :
myXML= new XML();
myXML.load("C:\menu.xml");
myXML.onLoad=loaded(success);
function loaded(success){
if(success) {trace("Ok");}
else {trace("! Ok");}
}
When the movie is "run" the following error occurs:
Error opening URL "C:\enu.xml"
My question:The file name is menu.xml but the error statement calls it enu.xml! Why?
Also why doesn't the xml file load into the movie?
Please download the movie and help!
javadi82
July 17th, 2003, 01:49 AM
source code for the xml file is:
<menu>
<mainitem>
<item>Alphabet</item>
<subitem>A</subitem>
<subitem>B</subitem>
</mainitem>
</menu>
lostinbeta
July 17th, 2003, 01:53 AM
Well I didn't set up any test files, but I noticed a few things wrong right off the bat...
1) You are exporting as Flash 5, go to File/Publish Settings and click on the Flash tab and choose Flash 6. Otherwise the dynamic event handlers won't work.
2) myXML.load("C:\\enu.xml")... enu.xml? Is that correct?
3) myXML.onLoad = loaded(success)... should be myXML.onLoad = loaded
javadi82
July 17th, 2003, 03:05 AM
since i don't have flash 6 i open the swf file in frhed and change it to flash player 06. then i open the file in flash player 06.(thanks to senocular,for the idea)
lostinbeta
July 17th, 2003, 03:08 AM
Oh, well if you are going through all of that, then I have no clue how to help you :-\
javadi82
July 17th, 2003, 03:33 AM
to lost in beta:
could you open the .fla and see what if it works for you.please do try it with an xml file of your own named menu.xml.
lostinbeta
July 17th, 2003, 11:42 AM
Yes, it worked.
I created the menu.xml file in the same directory as the .swf file (didn't feel like going through all the addressing), then used this code..
myXML = new XML();
//added ignoreWhite
myXML.ignoreWhite = true;
myXML.load("menu.xml");
myXML.onLoad = loaded;
function loaded(success) {
if (success) {
trace("Ok");
createTextField("xmltext1", 1, 100, 100, 200, 200);
xmltext1.text = "Successfully Loaded!";
} else {
trace("! Ok");
createTextField("xmltext2", 1, 100, 100, 200, 200);
xmltext2.text = "Unsuccessful!";
}
}
And when I tested the movie I got a textbox that said "Successfully Loaded!"
BTW: I added ignoreWhite in there because that is something you should always do when loading in XML. It removes all the excess/useless whitespace from the XML file.
eyezberg
July 17th, 2003, 03:55 PM
lost, all the above xml actionscript existed in Flash 5, so no pb with that...
java, when using test movie locally, always test with any files you wanna load in the same folder as your fla/swf, lots of bugs come from there! might just be that you need to escape the \ with \\.. try..
lostinbeta
July 17th, 2003, 03:57 PM
Eyez: ignoreWhite and createTextField() existed in Flash 5? I thought that was introduced in MX???? :q:
eyezberg
July 17th, 2003, 04:15 PM
not YOUR actionscript, the one he originally posted! ;)
lostinbeta
July 17th, 2003, 04:18 PM
Oh... ok, well ignoreWhite is in MY actionscript, but createTextField is in HIS .fla file. (the one in the attachment, not the one in the thread)
;) ;)
javadi82
July 18th, 2003, 08:47 AM
to eyez:I use most of the actionscript commands and functions in flash mx for my flash 5 files. I open frhed and convert the .swf into flash player 06 format.(thanks again senocular).
eyezberg
July 18th, 2003, 03:46 PM
@ lost: well i did say
all the above xml actionscript existed in Flash 5 and never looked at the fla.. ;)
@javadi: does it work then now?
would be nice when you ask stuff to tell us if it's solved or not..
lostinbeta
July 18th, 2003, 04:04 PM
Yea, im confuzzled :hangover:
I remember when sen posted the way to get Flash 5 files to act as Flash MX files so you can use the sintax, but I don't know if it works as well, so I don't know if this works.
So... does it?
javadi82
July 19th, 2003, 03:21 AM
YES YES YES.It does work! 'It' here implies two things:
1.Senocular's idea of writing actionscript for flash mx in flash 5 and then changing the .swf format to flashplayer 06 WORKS.
2.I had to only change the
myXML.onLoad=loaded(success) to
myXML.onLoad=loaded as lostin beta said and IT WORKED!
Thanks for the help!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.