I’m trying to access some variables from my parent in my child MC.
Parent code:
var data_history:String;
function finish_checkUp(event:Event):void{
var checkUp_stat:String;
checkUp_stat = data.check_UP_STAT;
if (checkUp_stat == "PASSED"){
data_history = "FALSE";
gotoAndPlay ("domain_check");
}
else if (checkUp_stat == "FAILED"){
data_history = "TRUE";
gotoAndPlay ("error_data_conflict");
}
else if (checkUp_stat == "FAILED_UN"){
data_history = "TRUE";
gotoAndPlay ("");
}
}
CHILD MC:
contt_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseClick);
contt_btn.addEventListener(MouseEvent.ROLL_OVER,contt_btnOver);
contt_btn.addEventListener(MouseEvent.ROLL_OUT,contt_btnOut);
function contt_btnOver(event:MouseEvent):void{
contt_btn.gotoAndPlay("over");
}
function contt_btnOut(event:MouseEvent):void{
contt_btn.gotoAndPlay("out");
}
function mouseClick(event:MouseEvent):void
{
trace (MovieClip(this.parent).data_history);
if (data_history == "TRUE"){
MovieClip(parent).gotoAndPlay("begin_erasing");
}
else if (data_history == "FALSE"){
gotoAndPlay("");}
}
Now as you can see, i have tried the trace method, but with no luck. Flash doesn’t report any errors regarding the trace method, but does report the two undefined vars (data_history). Ive tried to use the trace method above all the functions, at the top of the script, still the same errors though.
any ideas?
In the trace, you are referencing the data_history property through
this.parent. Assuming that traces your value, you need to adjust your if…else to reference the property through parent as well:If the trace you have in there throws an error, then the property never existed on parent.