Create dynamic button with actionscript
Post by efox | Date: 2008-08-01
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

Previous
Next
Tags: