View Full Version : XML to variables in movieclips

04-30-2001, 08:32 AM
I am using XML to store a number of variables. I parse the XML and assign the values from nodes to variables on the main timeline. This seems fine and I an able to show the variables in text fields.
My problem is with writing the variables to text fields within movie clips. I am this action within the movieclip to bring in the variable from the main timeline:
option1 = _root.option1;

this works in IE4, IE5.5. But in IE5.0 it setc the variable to just be

Any ideas?


04-30-2001, 08:41 AM
Strikes me that your IE5 plugin must be old to get an error like that.



04-30-2001, 04:48 PM
No, I wish that was it, but I have downloaded the latest plugin, and tried it on a number of machines.
It seems to work sometimes and not others, with the same browser, clearing the cache each time. Probably something to do with the amount of time to do all the work underneath. Still have no idea what to do about it.

05-01-2001, 03:49 AM
Can you post a line for us to check?



05-01-2001, 01:35 PM
Thanks Jesse, not definite what you mean by post a line, I am presuming you mean show the full code.
Ok, here goes -
on the first frame of the movie there is the following to load the xml -

LPXML = new XML();
function populateTextFields () {
DisposableXML = new XML();
TempXML = new XML();
ClickList = new Array();
DisposableList = new Array();
ClickList = LPXML.firstChild.childNodes;
i = 0;
while (i<=ClickList.length) {
if (ClickList[i].nodeName.toLowerCase() == "click") {
DisposableXML = ClickList[i];
DisposableList = DisposableXML.childNodes;
ii = 0;
while (ii<=DisposableList.length) {
TempXML = DisposableList[ii];
if (DisposableList[ii].nodeName.toLowerCase() == "lptitle") {
lptitle = lptitle +"<font type=\"Arial\" ><b>"+DisposableList[ii]+"</b></font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2intro") {
q2intro = q2intro+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "question2stem") {
question2stem = question2stem+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "question2prompt") {
question2prompt = question2prompt+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2partlyright") {
q2partlyright = q2partlyright+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2incorrect") {
q2incorrect = q2incorrect+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2correctfeedback") {
q2correctfeedback = q2correctfeedback+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2cancel") {
q2cancel = q2cancel+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2option1") {
q2option1=q2option1+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2option2") {
q2option2=q2option2+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2option3") {
q2option3=q2option3+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2option4") {
q2option4=q2option4+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2target1") {
q2target1=q2target1+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2target2") {
q2target2=q2target2+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
} else if (DisposableList[ii].nodeName.toLowerCase() == "q2target3") {
q2target3=q2target3+"<font type=\"Arial\" >"+DisposableList[ii]+"</font>";
ii = Number(ii)+1;
i = Number(i)+1;
LPXML.onLoad = populateTextFields;


the xml file contains the following -

<?xml version="1.0" ?><question>
<Qintro>To pursue an e-mail advertising strategy, an advertiser needs to use an e-mail distribution list.</Qintro>
<Questionstem>Which of the following do you think are useful sources that advertisers can use to generate e-mail distribution lists?</Questionstem>
<QuestionPrompt>Click the correct options and then click <b>Done</b></QuestionPrompt>
<Incorrect>You haven't chosen any of the correct options.</Incorrect>
<PartlyRight>You're partly right.</PartlyRight>
<CorrectFeedback>That's right.</CorrectFeedback>
<Cancel>The correct options are now highlighted.</Cancel>
<Option1>Purchase records</Option1>
<Option2>Public directories</Option2>
<Option3>Web site registrations</Option3>
<Option4>Subscription registrations</Option4>

<Q2intro>Web-enabled databases typically use HTML, XML, and SQL to carry out their various operations.</Q2intro>
<Question2stem>See if you can match each of these programming languages with its main function.</Question2stem>
<Question2Prompt>Click and drag each programming language to the function it is used to perform.When you're finished click <b>Done</b></Question2Prompt>
<q2Incorrect>You haven't matched any of the correct options.</q2Incorrect>
<q2PartlyRight>You're partly right.</q2PartlyRight>
<q2CorrectFeedback>That's right.</q2CorrectFeedback>
<q2Option1>HTML (Hyper Text Markup Language) <u>1</u></q2Option1>
<q2Option2>SQL (Structured Query Language) <u>2</u></q2Option2>
<q2Option3>XML (Extensible Markup Language) <u>3</u></q2Option3>
<q2target1>Creates and formats pages on the World Wide Web. <u>a</u></q2target1>
<q2target2>Requests information from a database. <u>b</u></q2target2>
<q2target3>Identifies, defines, transmits, and interprets different types of data. <u>c</u></q2target3>
<q2Cancel>XML is used to identify, define, transmit, and interpret different types of data. HTML is used to create and format pages on the World Wide Web. SQL is used to request information from a database.</q2Cancel>
<rollover1>Internet service providers have pursued legal action.</rollover1>
<weblink1>Now you have the chance to visit a web site that offers a large network of high-quality, targeted opt-in e-mail addresses.&lt;a href="http://www.postmasterdirect.com" target="_blank"&gt;&lt;b&gt;Link to website.&lt;/b&gt;&lt;/a&gt;</weblink1>


__________________________________________________ ____

The options are movie clips with buttons inside (to allow them to be dragged and dropped onto targets), on the first frame inside each there is a textbox called Option1, option2, etc. The action inside these is

q2option1 = _root.q2option1;

and thats most of what there is. The problem is with getting the text from the XML into these textboxes.

thanks again


05-02-2001, 02:12 AM
No no, I meant post a linK, stupid fast and innacurate typing :)

If we can't figure it out from seeing the file I'll take a look at that code (don't worry about the forum screwing it up, I can view it in the right format)



05-02-2001, 11:34 AM
Hi again,
I am sorry for the delay. I work off internal servers which are inside a firewall, so had to set up an external site. I uploaded the files and can't get them to load at all. As soon as I get it sorted I'll let you know.

thanks again,

ps. I have been trying a few things and it seems the problem is to do with levels. The file is loaded into level 1, but when I try it on level 0 there is no problem.

05-18-2001, 08:24 AM
The fact that loading into level0 gives no problems indicates that it is a paths issue to me. Check the paths to all variables and Movieclips carefully...

Try test publishing your movie (Ctrl Enter in Flash, then viewing all variables Ctrl Alt V and checking the object layout Ctr L... see if any of your paths are incorrect)



05-18-2001, 10:45 AM
Hi Jesse,
Thanks for all the help. I don't know what I'd do without your site!
I got that problem sorted out. The problem was to do with the way the XML was being parsed. I added in a loop to strip out the text nodes only and stick them into another (yes, yet another) Array.
Like so:

a=0; b=0;
while (a<=TempList.length){
if (Templist[a].nodeType == 1 ) {
FinalList[b] = TempList[a];

That seems to have solved the problem for the browsers.
Talk to you soon (as soon as I break something again!)

ps. What's the difference between a member and a new member?

05-18-2001, 10:51 AM
Every reply I make to this thread seems to do something wierd - one went all italics, the last one went bold...

05-19-2001, 05:59 AM
Good to hear it's fixed.
New Member = less than 50 posts, we changed the titles but the board has defaulted back to old settings since the database got stuffed up.

The reason your posts keep getting changed is that you use unfortunate variables :) [ i ] and [ b ] are reserved by the board to make text italic and bold, that's why I use k and j as counters :p

It doesn't matter though because I just click 'edit post' and it gives me the error free code you typed.