Skip to content

Instantly share code, notes, and snippets.

@aolba
Created October 29, 2013 19:09
Show Gist options
  • Save aolba/7220744 to your computer and use it in GitHub Desktop.
Save aolba/7220744 to your computer and use it in GitHub Desktop.
// Add any movieclip with (in this example) "my_mc" as the instance name.
makeButton(my_mc, my_mc_over, my_mc_out, my_mc_click);
function my_mc_over(evt:MouseEvent):void { trace("Rollover"); }
function my_mc_out(evt:MouseEvent):void { trace("Rollout"); }
function my_mc_click(evt:MouseEvent):void { trace("Clicked"); }
function makeButton(which_mc:MovieClip, overFunction:Function, outFunction:Function, clickFunction:Function):void {
which_mc.buttonMode = true;
which_mc.useHandCursor = true;
which_mc.mouseChildren = false;
which_mc.addEventListener(MouseEvent.MOUSE_OVER, overFunction);
which_mc.addEventListener(MouseEvent.MOUSE_OUT, outFunction);
which_mc.addEventListener(MouseEvent.CLICK, clickFunction);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment