InterviewSolution
Saved Bookmarks
| 1. |
Solve : Flash Variables? |
|
Answer» ACTIONSCRIPT 3.0 I have this code: Code: [Select]var W = 0; var C = 0; function CInfo_Open(e:MouseEvent):void { if (W == 1){ << Problems with WTeacher_Info.play(); <<This code var W = 0; if (C == 0) { CTeacher_Info.play(); var C = 1; } } C_btn.addEventListener(MouseEvent.CLICK,CInfo_Open); function CInfo_Close(e:MouseEvent):void { if (C == 1) { CTeacher_Info.play(); var C = 0; } } C_btn.addEventListener(MouseEvent.CLICK,CInfo_Close); function WInfo_Open(e:MouseEvent):void { if (C == 1){ << And This CTeacher_Info.play(); <<Code var C = 0; if (W == 0) { WTeacher_Info.play(); var W = 1; } } W_btn.addEventListener(MouseEvent.CLICK,WInfo_Open); function WInfo_Close(e:MouseEvent):void { if (W == 1) { WTeacher_Info.play(); var W = 0; } } W_btn.addEventListener(MouseEvent.CLICK,WInfo_Close); Now, when the movieclips "WTeacher_Info" and "CTeacher_Info" are played the first TIME, they OPEN a box, and when they play a SECOND time, the box closes. Im TRYING to make it so that if one box is open, and the other box's button is clicked, the open box closes FIRST, then the correct box opens. Am I defining my variables wrong?Quote from: EchoLdrWolf316 on December 22, 2008, 02:00:16 PM ACTIONSCRIPT 3.0 I'm not even close to an expert at ActionScript, but try that. HM, not quite, but it's close.I've messed with it, and I think I'm defining the variables wrong. Anyone know how to define a numeric variable?Figured it out: Code: [Select]var C:int = 0; var W:int = 0; //----------------------------------------------------------------------------- function Cinfo(e:MouseEvent):void { if (W == 1){ WTeacher_Info.play(); W = 0; } if (C == 0) { CTeacher_Info.play(); C = 1; } else if (C == 1){ CTeacher_Info.play(); C = 0; } } C_btn.addEventListener(MouseEvent.CLICK, Cinfo); //----------------------------------------------------------------------------- function Winfo(e:MouseEvent):void { if (C == 1){ CTeacher_Info.play(); C = 0; } if (W == 0) { WTeacher_Info.play(); W = 1; } else if (W == 1){ WTeacher_Info.play(); W = 0; } } W_btn.addEventListener(MouseEvent.CLICK, Winfo); //-----------------------------------------------------------------------------Good. |
|