PDA

View Full Version : Building 3D bar Chart from Text file - Almost there - HELP!


geebee2
12-26-2005, 08:07 PM
Hi All,

I borrowed this code that uses input from 2 text input fields to generate a bar chart. I want to alter this code to take dynamic data from a text file. I think I need some sort of multidimensional array right? Here is the existing code that is tied to a button.


on (release, keyPress "<Enter>") {
labelString = eval("box1");
dataString = eval("box2");

label = labelString.split(",");
data = dataString.split(",");

for (var i in data) {
data[i] = Number(data[i]);
}
n = data.length;
myColor = colorHex.slice(0, n);
gotoAndPlay(2);
}

}




I need to replace the variables label and data in the above example with dynamic data from a text file. This is what I have so far and it works getting the data that I need from the text file. This works as long as I don't tie it to a button - However when attaching this to a button nothing happens now..... I think I may have some logic issue


on (release, keyPress "<Enter>") {

// I would write something like:
varReceiver = new LoadVars();
varReceiver.load("external2.txt");
// get Label data into first array named myLabelArray
varReceiver.onLoad = function() {

this.myLabelArray = this.myLabelArray.split(",");
trace(this.myLabelArray);
label=this.myLabelArray;

// get score data into second array named myDataArray

this.myDataArray = this.myDataArray.split(",");
trace(this.myDataArray);
data=this.myDataArray;

for (var i in data) {
data[i] = Number(data[i]);
}
n = data.length;
myColor = colorHex.slice(0, n);
gotoAndPlay(2);


}

};