Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Flash Buttons

Sign in to follow this  




Today, I decided to make my life a little bit easier.

Normally, when I'm making a Flash Game, I do everything myself, including buttons. I use MovieClips to make my buttons, and I use ActionScript 2.0 classes to drive them.

Today is no different, but I've gotten tired of drawing buttons again and again.

So, I did some experimentation, and I made a button component that is pretty lightweight (the swf is about 5k and I've got six different button components in it).

There is a standard flash button component, and then a button that can be made in the library of an swf file, but I just didn't like either one (and John pointed out today that the normal button component has a significant footprint due to data binding and other junk that I just don't need or want).

The buttons that I tend to use fall into a few different categories:

1. Disabled and Enabled
2. Circular or Square
3. Short, Medium, and Long Width
4. Text or Icon

So I made six buttons (Round and Square in Short, Medium, and Long Widths), that support being Enabled or Disabled and having Text or Icons on them. And I only needed to use two ActionScript 2.0 classes to do it, and they will serve all of my needs nicely.

The sizes are 64x64, 128x64, and 192x64. If I want different sizes, I'll just scale the instances as long as I maintain a 1:1, 2:1, or 3:1 aspect ratio, I'll be fine. I may or may not need to make a 256x64 button for those long words, but time will tell on that, and it will be rather easy.

My buttons are "dumb". They don't really know how to do anything. The only things that they do are tell their parents when they are hovered over (really, they just send a tooltip), and they tell the parent when they have been clicked, sending a reference to themselves and their enabled/disabled state. It'll be up to the parent to actually do something about the button press. In the meantime, I can set the properties in the component inspector, lay out the buttons however I wish, and spend more time actually making the game rather than drawing the buttons.
Sign in to follow this  

1 Comment

Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!