PDA

View Full Version : Animating Button Class - How would you make one using Design Patterns?


peterpedr0
08-17-2007, 06:51 PM
I am trying to wrap my head around the use of design patterns. To do this I'm attempting to come up with the best structure of design patterns to create buttons which contain more functionality than the built in class SimpleButton.

For example, I want to create a structure for making buttons with animations between states (each of the states would be classes containing animations).

var button:AnimButton = new AnimButton();
button.upState = new UpState( button );
button.overState = new OverState( button );
button.downState = new DownState( button );

addChild( button );

Now I thought the best pattern for implementing this structure would be a State Machine Pattern, but I just can't get it working (without being extremely convoluted).

What design pattern's would you use to make a useful animating button structure?
Has anyone developed their own button class (or any UI element) for easily implementing animations and additional behaviors?