two button with single function
I want to create two buttons for single function and one button for one function. For example, I click button1, the screen will show "clicked1"
If I clicked button2, the screen will show "clicked2". If I click button1 and then click button2, it will show "two button are clicked". However, it does not work in two button with single function. What is the problem? Here is the code.
import flash.display.MovieClip;
import flash.events.MouseEvent;
var button1:MovieClip=new Button1();
button1.x=200;
button1.y=200;
addChild(button1);
var button2:MovieClip=new Button2();
button2.x=300;
button2.y=250;
addChild(button2);
button1.addEventListener(MouseEvent.CLICK, onClick);
button2.addEventListener(MouseEvent.CLICK, onClick2);
var isClicked:Boolean;
var isClicked1:Boolean;
function onClick(evt:MouseEvent):void{
isClicked=true;
trace("clicked1");
}
function onClick2(evt:MouseEvent):void{
isClicked1=true;
trace("clicked2");
}
if (isClicked&&isClicked1){
trace("two buttons are clicked");
}
