Create dynamic button with actionscript

In this article,  I want to talk about how to create dynamical button in actionscript. No design tools needed, just actionscript code.  see the following example, I hope it will be helpful to you.

//draw an button
var drawArea:Array = [[0, 0], [100, 0], [100, 20], [0, 20], [0, 0]];
this.createEmptyMovieClip("btn",0);
btn.beginFill("0x000000",100);
for (i=0; i<drawArea.length; i++) { 
i == 0 ? btn.moveTo(drawArea[i][0], drawArea[i][1]) : btn.lineTo(drawArea[i][0], drawArea[i][1]);

btn.endFill(); 


 //set position of the button
btn._x = (Stage.width/2)-btn._width/2;
btn._y = (Stage.height/2)-btn._height/2;
// button methon
btn.onRelease = function() { 
getURL("
http://www.foxarc.com", "_blank");
};




Comment: 0 | Read times: -
Announce commentary
Your name
Content
Validation code Code