I’m new to AS3. I am a mediocre AS2 programmer, but I’ve taken some java courses so I guess I’m not too clueless that I can’t eventually make the jump to AS3 : ) I have a new project that I am converting to AS3 from AS2 and am getting an error and am not sure what to do.
Background:
I need to create a scaled down version of Deal Or No Deal (with some major variations to the rules). I have a fla with a bunch of briefcase movieclips onstage named case1_mc, case2_mc, etc. There are 26 of them. I have a bunch of classes named Main.as (which is the document class for the fla), Briefcase.as, Game.as, Banker.as, etc.
My trouble is that within each briefcase mc there is a dynamic text field. I need to assign text to the dynamic text fields in each of the briefcase mc’s. Here is my code from the Main class that is the document class that is causing the problem. This function is called from the Main constructor, to initialize the briefcase objects (not the visual ones, but the ones that will hold data to be displayed in the visual ones as needed):
function generateCases(_totalNumCases) {
for (var i=1; i<=_totalNumCases; i++) {
//generate the Briefcase objects
this["case"+i] = new Briefcase(i);
//assign the Briefcase object's caseNum to the displayed briefcase movieclip
this["case"+i+"_mc"].num_txt.text = this["case"+i].getCaseNum();
}
//randomize the caseValues_arr and assign values to Briefcases
shuffledCaseValues_arr = dollarValues_arr.shuffle();
//assign the shuffledCaseValues_arr values to the correlating Briefcases
//NOT WORKING
var incrementArray:Number = 0;
for (i=1; i <=_totalNumCases; i++) {
this["case" + i].setCaseValue(shuffledCaseValues_arr[incrementArray]);
incrementArray++;
}
}
When I compile and run in Flash CS3 I get the following output error (I get no compile errors anymore after much editing!):
ReferenceError: Error #1056: Cannot create property case1 on com.vertexinc.dealornodeal.Main.
at com.vertexinc.dealornodeal::Main/com.vertexinc.dealornodeal::generateCases()
at com.vertexinc.dealornodeal::Main$iinit()
So it appears that it just cannot run the function because it can’t set the text properties of the briefcases? Any help is greatly appreciated! I had this working in AS2/Flash 8 but want to stick it out and get it going in AS3 as my first AS3 project!