Button Creation Flash MX

  • brendon
  • Born
  • Born
  • brendon
  • Posts: 1

Post 3+ Months Ago

I am trying to build a solar system for a game,

I would like each planet in the system to have a button generated from it.

as you probably realise I cannot have all the buttons already on the scene as I do not know how many planets each user will have.

Thus I would like to generate a button completely from actionscript.

I have done numerous searchers on google and various forums and a have come up empty handed.

Any help would be much appreciated, the button doesnt have to be anything fancy, a 40X40 square would be fine as i can minipulate it later.

Thank you for your time,
Brendon.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

here is one method
Code: [ Select ]
//function that uses drawing API to draw 40x40 square
MovieClip.prototype.makeButton = function() {
    this.clear();
    this.moveTo(0, 0);
    this.beginFill(0xE6E6E6, 100);
    this.lineTo(-20, 20);
    this.lineTo(20, 20);
    this.lineTo(20, -20);
    this.lineTo(-20, -20);
    this.lineTo(-20, 20);
    this.endFill();
};
//create new movieclip symbol dynamically
//then make it a square by using the makeButton function
this.createEmptyMovieClip("myButton1", 1).makeButton();
//assign button actions to the created clip
myButton1.onRelease = function() {
    trace("you clicked me!");
};
  1. //function that uses drawing API to draw 40x40 square
  2. MovieClip.prototype.makeButton = function() {
  3.     this.clear();
  4.     this.moveTo(0, 0);
  5.     this.beginFill(0xE6E6E6, 100);
  6.     this.lineTo(-20, 20);
  7.     this.lineTo(20, 20);
  8.     this.lineTo(20, -20);
  9.     this.lineTo(-20, -20);
  10.     this.lineTo(-20, 20);
  11.     this.endFill();
  12. };
  13. //create new movieclip symbol dynamically
  14. //then make it a square by using the makeButton function
  15. this.createEmptyMovieClip("myButton1", 1).makeButton();
  16. //assign button actions to the created clip
  17. myButton1.onRelease = function() {
  18.     trace("you clicked me!");
  19. };


But it would require you know how to use the drawing API and dynamic event handlers to make it easier to modify for your needs.

You can read a little info about these in the ActionScript reference in Flash, http://www.kirupa.com , and a bunch of other sites :)
  • rynoe
  • Banned
  • Banned
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Don't use all that API nonsense!

Make a swf of a planet that you can change properties and use
duplicateMovieClip actionscript.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.