Dear Kirupa Forum,
Need your help, I’m a beginner in Flash especially in AS3. I have a little project, as follow:
*** Assume instance name = MovieClip name
In layer [Display], I have 3 MC, they are mcDisplay1, mcDisplay2 and mcDisplay3, inside each this MC has mcPump1, mcPump2 and mcPump3.
In layer [Controller], I have mcController, inside this has txtName, btnClose, btnStart and btnStop.
My aim is, to Start/Stop the mcPump from different mcDisplay using only this mcController.
The script code below that I know is still not make satisfied:
//*****code begin here*****
//-----------
mcDisplay1.mcPump1.addEventListener(MouseEvent.CLICK, iController);
mcDisplay2.mcPump2.addEventListener(MouseEvent.CLICK, iController);
mcDisplay3.mcPump3.addEventListener(MouseEvent.CLICK, iController);
mcController.btnStart.addEventListener(MouseEvent.CLICK, startAction);
mcController.btnStop.addEventListener(MouseEvent.CLICK, stopAction);
mcController.btnClose.addEventListener(MouseEvent.CLICK, hideMe);
//-----------
mcController.visible=false;
//-----------
function iController(me:MouseEvent):void{
mcController.visible=true;
switch(me.currentTarget){
case mcDisplay1.mcPump1:
mcController.txtName.text=”Pump_1”;
break;
case mcDisplay2.mcPump2:
mcController.txtName.text=”Pump_2”;
break;
case mcDisplay3.mcPump3:
mcController.txtName.text=”Pump_3”;
break;}
}
//-----------
function startAction(me:MouseEvent):void{
switch(mcController.txtName.text){
case ”Pump_1”:
//mcPump1 Start;
break;
case ”Pump_2”::
//mcPump2 Start;
break;
case ”Pump_3”:
//mcPump3 Start;
break;}
}
//-----------
function stopAction(me:MouseEvent):void{
//similar to startAction
}
//-----------
function hideMe(me:MouseEvent):void{
mcController.visible=false;
}
//-----------
//*****code end here*****
Please if anyone of you have a better idea to share to me to get the aim.
Thanks
sangjagoan