PDA

View Full Version : New to XML


BuffySummers
06-05-2003, 09:46 AM
So I have this project for this company I am a intern with that involves using Flash and XML. I have never done anything like this before and I've tried using some of the tutorials to get a better understanding of the concept. I can make certain things work after using the tutorials (XML 101) but I can't really expand beyond that because I have no freaking clue what's going on and why things work and why they don't. This project...I am supposed to take an existing Flash/XML concept this company has and expand it to do other things. The problem is, if I modify or expand on it, the mods don't work. I have tried reconstructing what they have and changing it to meet my needs. Still doesn't work. grrr.

Having said that, I'm trying to use XML to populate a movie which is loaded into Flash via the XML with images and text. The movie is to play itself through, then after it is finished, tell the root timeline to move to the next frame and load a new movie and some new content. This is suppose to happen as many times as needed...the concept is simple enough so far. I can get the movie to load into Flash but I can't get the other info to populate it. The debug Variables area tells me that I am getting a huge amount of variables that shouldn't be there. It's super annoying.

Am I being to wordy? Anyway, this is the code I have thus far. Yes, it's modified from a tutorial, but like I said, I don't really understand what's going on (and I can't buy a book on it as of right now...)

FRAME 1

System.useCodepage = true;
function Article(ads, bahnhof, num, layout, content1, content2, content3, content4, content5, content6, text1, text2, text3, text4, text5) {
this.ads = ads;
this.bahnhof = bahnhof;
this.num = num;
this.layout = layout;
this.content1 = content1;
this.content2 = content2;
this.content3 = content3;
this.content4 = content4;
this.content5 = content5;
this.content6 = content6;
this.text1 = text1;
this.text2 = text2;
this.text3 = text3;
this.text4 = text4;
this.text5 = text5;
}
function makeArray(success) {
var i, j, mainTag, ads, bahnhof, num, layout, content1, content2, content3, content4, content5, content6, text1, text2, text3, text4, text5;
if (success) {

for (i=0; i<=moXML.childNodes.length; i++) {
if (this.childNodes[i].nodeValue == null && this.childNodes[i].nodeName == "advertise") {
mainTag = this.childNodes[i];
ads = mainTag.attributes["ads"];
bahnhof = mainTag.attributes["bahnhof"];
//trace(+ mainTag.attributes["bahnhof"])
}
}
for (i=0; i<=mainTag.childNodes.length; i++) {
if (mainTag.childNodes[i].nodeName == "spot") {
adTag = mainTag.childNodes[i];
num = adTag.attributes["num"];
for (j=0; j<adTag.childNodes.length; j++) {
if (adTag.childNodes[j].nodeName != null) {
if (adTag.childNodes[j].nodeName == "layout") {
layout = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content1") {
content1 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content2") {
content2 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content3") {
content3 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content4") {
content4 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content5") {
content5 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "content6") {
content6 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "text1") {
text1 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "text2") {
text2 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "text3") {
text3 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "text4") {
text4 = adTag.childNodes[j].firstChild.nodeValue;
} else if (adTag.childNodes[j].nodeName == "text5") {
text5 = adTag.childNodes[j].firstChild.nodeValue;
}
}
}
thisArticle = new Article(ads, bahnhof, num, layout, content1, content2, content3, content4, content5, content6, text1, text2, text3, text4, text5);
articles.push(thisArticle);
delete thisArticle;
}
}
_root.gotoAndPlay(2);
}
}
var articles = [];
moXML = new XML();
moXML.ignoreWhite = true;
moXML.onLoad = makeArray;
moXML.load("poster.xml");
stop();

FRAME 2
Where "layout" is an empty movie clip on the stage.

_root.onEnterFrame = function() {
i=(_currentframe-1)
trace (i)
layout.loadmovie(articles[i].layout);

layout.text1 = ""+articles[i].text1+"";
layout.text2 = ""+articles[i].text2+"";
layout.text3 = ""+articles[i].text3+"";
layout.text4 = ""+articles[i].text4+"";
layout.text5 = ""+articles[i].text5+"";

layout.content1.loadmovie(articles[i].content1);
layout.content2.loadmovie(articles[i].content2);
layout.content3.loadmovie(articles[i].content3);
layout.content4.loadmovie(articles[i].content4);
layout.content5.loadmovie(articles[i].content5);
layout.content6.loadmovie(articles[i].content6);
}

stop();


Thanks in advance! If anyone can point me in the direction of a good reference so I can learn why things work/don't work in regards to Flash/XML I would be very happy and I will cheer wildly and maybe even do a little dance.

JL

BuffySummers
06-05-2003, 11:01 AM
I neglected to mention, I realize the onEnterFrame action in the second frame causes it to constantly repeat the function. I can fix that without a problem...I just forgot about it last night.