How can I simplify the code in this situation?
I want to create some interaction about ABCDEFGHIJKLM objects. If I l click A and B, the screen will show F. If I click A and C, it will show G. If I click A and D. it will show F..etc. When I mouseove A , it will show only L. If I mouseover B, it will show M only. In this situation, I need to create each eventListener (MouseoverA MouseOverB CLICK A, CLICK B, bothAandBClick, bothAandCClick, bothAandDclick......) Can I use other method to simplify the code?
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.ui.Mouse;
var redbtn:MovieClip=new Redbtn();
redbtn.x=321;
redbtn.y=13;
addChild(redbtn);
var yellowbtn:MovieClip=new Yellowbtn();
yellowbtn.x=130;
yellowbtn.y=106;
addChild(yellowbtn);
var bluebtn:MovieClip=new Bluebtn();
bluebtn.x=726;
bluebtn.y=89;
addChild(bluebtn);
var blackbtn:MovieClip=new Blackbtn();
blackbtn.x=236;
blackbtn.y=479;
addChild(blackbtn);
var greenbtn:MovieClip=new Greenbtn();
greenbtn.x=590;
greenbtn.y=457;
addChild(greenbtn);
var page1:MovieClip=new relationship();
var redBtnClicked:Boolean;
var blueBtnClicked:Boolean;
redbtn.addEventListener(MouseEvent.CLICK, onRedBtnClick);
redbtn.addEventListener(MouseEvent.ROLL_OVER, onRedOver);
redbtn.addEventListener(MouseEvent.ROLL_OUT, onRedOut);
bluebtn.addEventListener(MouseEvent.CLICK, onBlueClick);
bluebtn.addEventListener(MouseEvent.MOUSE_OVER, onBlueOver);
function onRedOver(evt:MouseEvent):void{
trace("redover");
redbtn.gotoAndStop(2);
}
function onRedOut(evt:MouseEvent):void{
trace("redout");
redbtn.gotoAndStop(3);
}
function onBlueOver(evt:MouseEvent):void{
trace("blueover");
}
function onRedBtnClick(evt:MouseEvent):void{
redBtnClicked=true;
bothClickedF();
}
function onBlueClick(evt:MouseEvent):void{
blueBtnClicked=true;
bothClickedF();
}
function bothClickedF():void{
if (blueBtnClicked&& redBtnClicked){
trace("two buttons are clicked");
addChild(page1);
redBtnClicked=false;
blueBtnClicked=false;
}
}
page1.trailer_sex.addEventListener(MouseEvent.CLICK, page1Click);
function page1Click(evt:MouseEvent):void{
removeChild(page1);
}