Friday, 5 March 2010

Our Project: The Beginning

Now that we've decided we are not using Arduino we needed to decide on what we will use for our visual element. We have decided that using flash and actionscript is the way forward. Jon, being the more technical part of the team, has come up with some code that will parse the XML that will be produced by the program we are using:

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("data.xml"));

function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
Parse(xmlData);
}

var address = new Array(); ...

function Parse(Input:XML):void {
var Children:XMLList = Input.item.children();

for each (var Info:XML in Children) {

if (Info.name() == "address") {
address[i] = Info;
}

Fdetect[i] = temp.substring(11,13) + temp.substring(14,16) + temp.substring(17,19);

if (Fdetect[i] <>
style="font-size:78%;">Earliest = Fdetect[i];
}


Apart from parsing the XML this code also picks out data by its tags and puts it into the array you can see. An 'if' statement is used to cycle the array index. The Fdetect part you can see is uses substring to extract the date and time and to put them next to eachother so they are easier to read. The final 'if' statement checks if a date and time is more recent than the currently stored date and time for a particular device. If it is then it replaces the stored value. This allows flash to find the earliest and latest time for all of the data which will prove useful for the visual side of things.

No comments:

Post a Comment