even though i’ve worked alot with Flash i still get frustrated with some things i cant understand… I’ve got a personal project that takes data off a weather station and displays it. It also takes data from another XML, data that i write by hand.
At the first frame of my timeline i have all the actions and then some animation occurs that puts all the panels in place and stops there. With the 1st XML file (the weather data) everything works fine. But with the 2nd XML file i get some weird problems.
My actions are like this (1st frame of main timeline):
//get the name of an XML node and return its number
function getNodeByName(nName:String){[INDENT] for (i=0; i<xmlNode.childNodes.length; i++){[INDENT] if(xmlNode.childNodes*.nodeName==nName){
return i;
}
[/INDENT]}
[/INDENT]}
function loadXML(loaded) {[INDENT] if (loaded) {[INDENT] xmlNode = this.firstChild.childNodes[0];
vThermo = xmlNode.childNodes[getNodeByName(“temp”)].firstChild.nodeValue;
vBaro = xmlNode.childNodes[getNodeByName(“currentpressureinmb”)].firstChild.nodeValue;
//etc…
setSky();
play();
[/INDENT]}
[/INDENT]}
stop();
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“stationData.xml”);
All this has always worked fine
then, with the other XML i decided to add this:
function loadCalendarData(loaded) {[INDENT] if (loaded) {[INDENT] var calendarData:Array = new Array();
totalCalendarEntries=this.firstChild.childNodes.length;
//trace(totalCalendarEntries);
for (i=0; i<totalCalendarEntries; i++){[INDENT] calendarData*=this.firstChild.childNodes*.childNodes[0].nodeValue;
trace(calendarData*);
[/INDENT]}
[/INDENT]}
[/INDENT]}
xmlDataCalendar = new XML();
xmlDataCalendar.ignoreWhite = true;
xmlDataCalendar.onLoad = loadCalendarData;
xmlDataCalendar.load(“calendar.xml”);
this also works. It reads the data from the XML and the **traces **show that everything is fine.
Now all those stuff loads and the timeline plays. After 50-60 frames all the panels are in place and the animation stops. Then action INSIDE the panels read the variables created before and display the data. Once again it works fine for the station data (my 1st XML) but the data from the 2nd XML file (that are traced and were loaded) are “undefined”…
An example of my code is this (within a Movie Clip that reaches back to the parents):
for(i=0; i<_parent._parent._parent.calendarData.length; i++){[INDENT] calendarText.text+=_parent._parent._parent.calendarData*+"
“;
trace(i+”>>"+_parent._parent._parent.calendarData*);
[/INDENT]}
however the _parent._parent._parent.calendarData is undefined now! (yes i’m sure the depth is correct)
So what is going on? Is flash at some point destroying the variable? I don’t have any other code on my main timeline other than a “stop();” so i cannot understand what could be wrong…
to get a better idea my “work-in-progress” is this: http://weather.locus-delicti.com
(without the 2nd XML implemented)
Any ideas?
Thanx for reading