« Math on the Web: A Status Report | Main | global from a movieclip timeline »

Thinking out loud...flash

I'm just thinking outloud, here...puzzling over how to approach part of a complex project.

Problem: A simulation with three steps, which must play in sequence. Under different treatments, selected by the user, each step may differ. Look up what should happen when at each step, for a treatment. How do I store this info in a way that can be easily looked up with same method each time?

First, I thought about arrays. Something like

simPlot = newArray[[normal, 1,1,1], [spider,1,0,0],...];

That could work, but there are several treatments, and it's hard for me to keep track of index numbers for each, when calling for the values in another function.

I was looking up info on Arrays at Helen Triolo's actionscript-toolbox. That gave me the idea to use a string for saving the simulation plot, and then use "split" and read the data like an array:

normalSim = "1:1:1"; // normal: fire action potential, release ACh, contract muscle
snakeSim = "0:0:0"; // snake: no current, no ACh release, no contraction of muscle

Then write a general function for getting the plot for any condition (treatment):

getPlot = function(treatment){
   simPlot = treatment.split(":"); // split string to array of steps for this treatment
   trace(simPlot[0]); //what is first step?
}

Then, when it's time to run that part of the simulation, call:

getPlot(normalSim);

Well, I'm going to try this out now.