/ Published in: ActionScript 3
Because making a button out of a movieclip in AS3 is ridiculously code-heavy, I wrote a simple function to set the needed values with only a couple of lines. You need the function placed within your code, after which you simply call it and then define the over/out/click functions for your movieclip.
Expand |
Embed | Plain Text
// 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); }
Comments
Subscribe to comments
You need to login to post a comment.

I was able to create a button, but what are the next steps to link to another function? Once I click on the button, I want it to load another set of code that I have.
In brief, I need the button click to load an external XML data field in a dynamic text box. I have the code figured out to load the XML, but am still having difficulty loading the XML data in a dynamic text box. If you would be willing to take a look at the code that would be awesome.
Thank you.