nightkarnation
04-17-2007, 08:49 PM
Ok...this is a very small part of the complete code from a game im creating and i would really appreciate some help on this function:
mcBtnComputer.onRelease = function() {
//Goal: perform random computer selection
var computerCheck:String = new String();
//computerCheck string going to make sense later
var tStats:Array = new Array();
tStats[0] = "mojo";
tStats[1] = "flavour";
tStats[2] = "yeah";
//randomize tNum from 0 to 2
tNum = random(2);
computerCheck = tStats[tNum];
//computerCheck = mojo or flavour or yeah (up to here works fine)
trace(computerCheck);
//loadVars as tGirls2 (working fine)
var tGirls2:LoadVars = new LoadVars();
tGirls2.load("pics/tGirl"+player2Randomizer+".txt");
tGirls2.onLoad = function() {
//HERE I NEED HELP: if i try: computerSelection = tGirls2.mojo; <--works fine
//but if i try as below its not working and i need it like this because i want to
//randomize it
computerSelection = Number(tGirls2.computerCheck);
//computerSelection = NAN ... why?? remember before on
//trace computerCheck was displaying or mojo or flavour or yeah
trace(computerSelection);
};
};
the txtfile has 3 variables
&mojo = 10&
&flavour = 8&
&yeah = 6&
mcBtnComputer.onRelease = function() {
//Goal: perform random computer selection
var computerCheck:String = new String();
//computerCheck string going to make sense later
var tStats:Array = new Array();
tStats[0] = "mojo";
tStats[1] = "flavour";
tStats[2] = "yeah";
//randomize tNum from 0 to 2
tNum = random(2);
computerCheck = tStats[tNum];
//computerCheck = mojo or flavour or yeah (up to here works fine)
trace(computerCheck);
//loadVars as tGirls2 (working fine)
var tGirls2:LoadVars = new LoadVars();
tGirls2.load("pics/tGirl"+player2Randomizer+".txt");
tGirls2.onLoad = function() {
//HERE I NEED HELP: if i try: computerSelection = tGirls2.mojo; <--works fine
//but if i try as below its not working and i need it like this because i want to
//randomize it
computerSelection = Number(tGirls2.computerCheck);
//computerSelection = NAN ... why?? remember before on
//trace computerCheck was displaying or mojo or flavour or yeah
trace(computerSelection);
};
};
the txtfile has 3 variables
&mojo = 10&
&flavour = 8&
&yeah = 6&