-
Flash MX XML parser does not work like Flash 5 ?
Hey Flashkit,
I have just finished lengthy project for a client in Flash 5 where it parses a single long xml file at the beginning of the flash movie and then displays different content depending on where you navigate through the rest of the movie. I have perfected it and it is snag free until now. The client would like to export the project in Flash MX. Once I did this the project no longer displays any XML content. I am not sure but I do not think the XML is being parsed anymore whatsoever.
I have put these checks in the place and no xml status errors appear nor does the "we made it" text.
brochureXML = new XML();
brochureXML.load("brochure.xml");
tellmekid = brochureXML.status; //Just a text field
if (brochureXML.loaded == true) {
doesitload = "we made it"; //Just a text field
brochureXML.parseXML("brochure.xml");
}
Sorry I do not have a soure files to post, and I know this may be a wide open question. But would any of you suggest where I may begin? I feel it may be an encoding issue for the xml file in Flash MX.
Any help is appreciated, Thanks,
- Jimmy
-
You need to use the onLoad handler... loading XML is asyncronous - it'll happen when it happens... the code will keep going even if the XML doc hasn't finished.
Code:
brochureXML = new XML();
brochureXML.onLoad=handleLoad;
brochureXML.load("brochure.xml");
function handleLoad(booleanStatus){
trace(booleanStatus);
trace(brochureXML.status);
}
You don't need to call the parseXML function- it get's called once the XML document has finished loading.
You might also need to look into the 'ignoreWhite' property...
-
To VAYKENT
Hey VAYKENT,
I have adapted your scripts and they work well, they give me feedback about loading the xml, boolean status, and xml status.
brochureXML = new XML();
brochureXML.load("brochure.xml");
brochureXML.onLoad = handleLoad;
function handleLoad(booleanStatus) {
checksforload = "made it";
checksforload1 = (booleanStatus);
checksforload2 = (brochureXML.status);
}
Whether I export the project in Flash 5 or MX these scripts work perfectly, however the project continues to fail to load the xml when exported to MX. The only thing I am doing differently is exporting to MX and that there in lies the problem.
Have any other suggestions?
- Jimmy
-
Could you describe what you mean by - '...fail to load the xml...'? What are the trace statments inside the handleload function returning?
-
To VAYKENT
VAYKENT,
checksforload = "made it";
checksforload1 = (booleanStatus);
checksforload2 = (brochureXML.status);
returns
made it
true
0
While exporting in Flash 5 the following line fails to load the xml content. When I comment out this line the movie works as expected.
brochureXML.ignoreWhite = true;
Could poor xml formatting be causing it to fail? But wait a minute the xml status returns 0 which means that it is formatted correctly. What does not make sense here?
- Jimmy
-
-
Flash MX XML parser does not work like Flash 5
Hey Richard,
Thanks for your help you are quite right. The xml content was being loaded just fine. By the way your custom scripts were working correctly too. But the xml loading and formatting status was not where to look for a solution.
Wondering why setting brochureXML.ignoreWhite = true; in F5 had the effect of breaking the movie's navigation...still I am not quite sure...but I have removed this line. By Default ignoreWhite = false; so there is no need to keep write the script.
Back to my original question, Does the Flash MX XML parser work like the Flash 5 XML parser and the answer is "Perhaps No".
In the project when a Next button is used it calls the following snippet of code
function updateContent() {
mainTag = new XML();
mainTag = brochureXML.childNodes;
//brochureNodes = mainTag[2].childNodes;
brochureNodes = mainTag[1].childNodes;
for (i=0; i<=brochureNodes.length; i++) {
// Much more came after this but you get the gist
}
Essentially this function creates a new xml object and sets the brochureNodes variable to the 2nd array item of the xml object. This is used to determine which content to load in the rest of the movie. When viewing this xml object in its entirety in F5 you would see 2 commas prior to the first childNode. When doing the same in FMX you would see only 1 comma prior to the first childNode. (The only difference was what export mode F5 or FMX was used) So the navigation of the project failed and no content would display. The remedy was to make the brochureNodes variable look at the 1st array item of the xml object. Now everything works as expected.
Thanks again,
- Jimmy
-
Glad it ended up working out... sorry I couldn't help more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|