Answered
changing variables in .as file
Hi.
I have a main.swf and sub1.swf, sub2.swf,... subN.swf files. They all use variables contained in myCode.as file. The sub... files are loaded on empty movie clips on the main.swf.
The myCode.as file has:
class myCode {
var bReady1:Boolean = false;
var bReady2:Boolean = false;
...
var bReadyN:Boolean = false;
}
All the sub... files have:
var f_N:myCode = new myCode();
this.onEnterFrame = function () {
if (f_N.bReadyN == true) {
trace ("Ready "+N);
f_N.bReadyN = false;
}
}
Finally, on the main.swf I have some buttons, each corresponding to a sub... file.
var f_main:myCode = new myCode();
this.btButtonSubN.onPress = function () {
f_main.bReadyN = true;
}
So, the way I figured this would work was: I press the button; bReadyN's value becomes "true"; on the next onEnterFrame, subN.swf sees bReadyN is true and traces the string. But I guess this isn't the correct way to do this, f_main.bReadyN and f_N.bReadyN don't seem to see the same variable, and I don't know why. Do they "create" new variables? All help is most welcome, thanks in advance!
João
I have a main.swf and sub1.swf, sub2.swf,... subN.swf files. They all use variables contained in myCode.as file. The sub... files are loaded on empty movie clips on the main.swf.
The myCode.as file has:
class myCode {
var bReady1:Boolean = false;
var bReady2:Boolean = false;
...
var bReadyN:Boolean = false;
}
All the sub... files have:
var f_N:myCode = new myCode();
this.onEnterFrame = function () {
if (f_N.bReadyN == true) {
trace ("Ready "+N);
f_N.bReadyN = false;
}
}
Finally, on the main.swf I have some buttons, each corresponding to a sub... file.
var f_main:myCode = new myCode();
this.btButtonSubN.onPress = function () {
f_main.bReadyN = true;
}
So, the way I figured this would work was: I press the button; bReadyN's value becomes "true"; on the next onEnterFrame, subN.swf sees bReadyN is true and traces the string. But I guess this isn't the correct way to do this, f_main.bReadyN and f_N.bReadyN don't seem to see the same variable, and I don't know why. Do they "create" new variables? All help is most welcome, thanks in advance!
João
