how to create dynamic button in actionscript

At first, it is a very simple tip.Maybe… anybody knows how can we create dynamic button in flash as we create textfield dynamically using this MovieClip.createTextField(), In this article, it shows how to creat dynamical button in actionscript. No design tools will be used, it is just actionscript code. Ok, let’s see the following code, hope it is what you are looking for and will be helpful to you.

// paint
var G:Array = [[0, 0], [80, 0], [80, 20], [0, 20], [0, 0]];
for (i=0; i<G.length; i++) {
i == 0 ? btn.moveTo(G[i][0], G[i][1]) : btn.lineTo(G[i][0], G[i][1]);
// set button position
btn._x = (Stage.width/2)-btn._width/2;
btn._y = (Stage.height/2)-btn._height/2;
// button methon
btn.onRelease = function() {
getURL("", "_blank");
Share and Enjoy:
  • Digg
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to

RSS Feed   RSS Feed     Email Feed  Email Feed Follow us Follow us
You can leave a response, or trackback from your own site.

5 Responses to “how to create dynamic button in actionscript”

  1. Einar says:

    Hi, do you have the *.fla file?

  2. Mia says:

    Thank you very much!
    You helped me alot!

  3. Good tuto to create dynamic button in actionscript. Very helpful

  4. Mel says:

    sometimes tha hardest things is the simpliest solution.
    i was trying a bit diferent
    a) i was creating emptyMovieClip ( for parent lets say container )
    b) i was filling the area to llok like box
    c) i was creating a text field call it wat ever
    d) i was creating a next layer ( dynamically always ) to do the BTN job

    Now thanks to u things is mutch easier and i feel like writting a THANKS A LOT.

Leave a Reply