Update on the Simulation project and the Sports Museum Kiosk

| | Comments (0)

I haven't posted for a while, mostly because I just hadn't had that much to say, but have also been busy with other things.

I blew the dust off the actionscript I'd written for the anesthesiology simulation with the idea of simplifying it and adding a couple of things. I don't remember if I mentioned before that I will be putting together a hands-on workshop for the 8th Annual International Meeting on Simulation in Healthcare in San Diego this coming January. Sounds pretty hoity-toity. I'll basically be showing people the technical end of how I put this simulation together and how they can use the same template to create other simulations in the healthcare field. And who knows, maybe some rich southern-California company will offer me a job with a huge raise to create such apps for them. And maybe monkeys will fly out of my butt, too.

Anyway, back to the sim. What I wanted to do in this version was to simplify wherever I can. So, I decided to drop using XPath, as cool and as hip as it is, because I was afraid that people would forget to use the data binding part of it and would be frustrated that their code is right but that it doesn't work for them. So I used my more recently acquired understanding of XML to pull in the data and parse it. Once I homed in on the correct path to the data I needed, it was simply a matter of changing one number to get the data for each different field from the database and push it all into their respective arrays. Here is what the code now looks like:


sims_xml.load('xml/sim.xml');
function processXML(xmlDoc_xml) {

// first we start a loop to get all the data from each field from each record

for (var n = 0; n<xmlDoc_xml.firstChild.childNodes[4].childNodes.length; n++) {

// each array corresponds to a field in each record
// the first one is the scene number
numberArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[0].firstChild.firstChild);
// then comes the title of the scene
titleArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[1].firstChild.firstChild);
// this is the photo associated with each scene
imageArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[2].firstChild.firstChild);
// this is the description of what going on in the scene
descriptionArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[3].firstChild.firstChild);
// this is the question that is posed to the user
questionArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[4].firstChild.firstChild);
// the next 4 things are the possible choices
choice1Array.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[5].firstChild.firstChild);
choice2Array.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[6].firstChild.firstChild);
choice3Array.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[7].firstChild.firstChild);
choice4Array.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[8].firstChild.firstChild);
// the next 4 tell the simulation which scene to go to if that choice is picked
choice1DestinationArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[9].firstChild.firstChild);
choice2DestinationArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[10].firstChild.firstChild);
choice3DestinationArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[11].firstChild.firstChild);
choice4DestinationArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[12].firstChild.firstChild);
// this is the background image for the simulation (could be different rooms, for example)
backgroundArray.push(xmlDoc_xml.firstChild.childNodes[4].childNodes[n].childNodes[13].firstChild.firstChild);

}
}

sim_xml.load('sim.xml');


Ok I see your eyes glazing over. The important thing about the above code is this - once I got the code right for one data field, if you look closely, each one thereafter was one number more (look at the last number in brackets for each line). Also note that they must be in the order that they appear in the XML file, so if you decide to add a field in the database, it's best to export it with that field at the end or it will hose the code.

The reason I mentioned the Sport Museum Kiosk was that what I learned in that project I'm also applying here in the sim. The kiosk has been used by the general public now all football season. The one problem we had with it was that occasionally it would act completely weird. Data would get confused with other data and the scrolling list of names would suddenly scroll to the end without even touching it. I was unable to duplicate this problem on my Mac. Worked perfectly every time. What I eventually came to figure out was that the interface was offering links to data that had not fully loaded yet. So, what I had to do was move the display of the links back a frame from where the XML is loaded, then tell it specifically to go to the next frame once all the data is loaded. So far so good. No more complaints. I think I have this problem licked. I'm employing the same strategy with the simulation. Make sure the gun is loaded before you try to fire it.

In a separate version of the simulation from what I'm doing for the workshop, I'll add some features like having a timer and a default scene for the sim to go to if someone takes too long to decide. Another feature is what we might call a dice. By that I mean that if the chances are 80% that something should happen, the Flash simulation should do something else 20% of the time. I haven't fully worked this part out, but I think I have an idea how I'm going to do it. It may involve another field for a time limit and one for the default scene to go to if they don't choose quickly enough.

As far as the 20% of the time idea goes, I'm not so sure how to implement this yet. If you had four different choices, you might have 4 different alternate outcomes other than the one that it would go to 80% of the time. Or perhaps there are only two real results, I don't know. It may depend on what the choices are. We will have to discuss this further, and it definitely won't be something we implement for the workshop in San Diego.

Well, that's all for now. I already wrote a lot more than I'd planned to write.

Leave a comment

About this Entry

This page contains a single entry by PATRICK JOSEPH BESONG published on October 31, 2007 2:26 PM.

Adobe Max 2007 Conference - Day 3 was the previous entry in this blog.

Test of h.264 Video Playing in Flash Player via Blog Space is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.24-en