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.

  1. // paint
  2. var G:Array = [[0, 0], [80, 0], [80, 20], [0, 20], [0, 0]];
  3. this.createEmptyMovieClip("btn",0);
  4. btn.beginFill("0x000000",100);
  5. for (i=0; i<G.length; i++) { 
  6. i == 0 ? btn.moveTo(G[i][0], G[i][1]) : btn.lineTo(G[i][0], G[i][1]);
  7. } 
  8. btn.endFill();
  9. // set button position
  10. btn._x = (Stage.width/2)-btn._width/2;
  11. btn._y = (Stage.height/2)-btn._height/2;
  12. // button methon
  13. btn.onRelease = function() { 
  14. getURL("http://ntt.cc", "_blank");
  15. };
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

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

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

  1. Einar says:

    Hi, do you have the *.fla file?
    regards!

  2. Mia says:

    Hello
    Thank you very much!
    You helped me alot!
    Regards,
    Mia

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

Leave a Reply