OK. I need help. I mean I really really need some help.
I’m feeling like a complete moron here, and I’ve posted before but to no avail, and now I think i’ve done EVERY tutorial on the web and I don’t know what to do. I think this should be easy, but for some reason it just doesn’t work out right in my head. I really sincerely have tried. I’m not the super actionscript guru but I really need to do this, and I’ve not gotten anywhere…
So I’m posting again.
Here goes.
I want to do the following:
Store a list of, say, clients, with various children in an external XML file. It looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mycClients>
<client>this is the name of the client</client>
<descrip> this is the description of the client</descrip>
<clientProjects>
<project name = "this is a project"> and these are the details of the first project </project>
<project> this is another project</project>
<project> this is the third project for selected client.
<URL>http://www.linktoproject.com/</URL> </project>
</clientProjects>
<clientsFriends>
<URL>http://www.clientsfriend.com/</URL>
<URL>http://www.linktoproject.com/</URL>
<URL>http://www.linktoproject.com/</URL>
<URL>http://www.linktoproject.com/</URL>
</clientsFriends>
</client>
<client>this is the name of the client</client>
<descrip> this is the description of the client</descrip>
<clientProjects>
<project name = "this is a different project"> and these are the details of the first project </project>
<project> this is a completely different project</project>
<project> this is yet another project.
<URL>http://www.linktoproject.com/</URL> </project>
</clientProjects>
<clientsFriends>
<URL>http://www.clientsfriend.com/</URL>
<URL>http://www.linktoproject.com/</URL>
<URL>http://www.linktoproject.com/</URL>
<URL>http://www.linktoproject.com/</URL>
</clientsFriends>
</client>
</myClients>
At this point, it may be a bit of a frankenstein, because I don’t know where my problem might be, so I keep changing it…I’ve got some misc. attributes floating around in there, because I thought that might be better…
Anyway…when the user clicks a BUTTON (not a dynamic button, but one I place on the stage) I want to load all the client’s projects. When the user clicks another button, I wan tto load all of the client’s friends. When the user clicks a third button, I want to load the description of the client.
Into a SIMPLE text box. Just a regular old dynamic text box which I have placed on the stage myself.
When a new button is clicked, the previous data is replaced with the new data.
Here’s my total frankenstein of a piece of AS, which now no longer makes sense to me.
clientArray= new Array();
projectArray = new Array ();
descriptArray = new Array ();
var clientXML:XML = new XML();
objL.ignoreWhite = true;
objXML.onLoad=loadXML;
objXML.load("clientxml.xml");
function loadXML(success:Boolean):Void{
if (success) {
_root.clientCount = this.firstChild.childNodes.length;
_root.pushArray();
}
else {
trace("problems");
}
}
function pushArray() {
for (var count = 0; count < _root.clientCount; count ++) {
var nodeObj = objXML.firstChild.childNodes [count];
projectArray[count] =nodeObj.attributes.clientProjects;
descriptArray[count] = nodeObj.attributes.descript;
friendArray[count]= nodeObj.attributes.clientsFriends;
}
}
What am I doing wrong? What am I missing? Why is this so hard?! Or is it?
I just want to keep this all as simple as possible so that I can learn to do it right.
Please don’t chastise me for being desperate and posting this again. I have just read an entire book on XML and still don’t get it. Literally.
Please please please help.
Thank you in advance.
-B