Seems I spend too much time coding menu groups of “complex buttons” (meaning buttons that may or may not animate, but remain selected (in down state) after clicked) - also seems the question gets asked quite a bit in many different. It’s not incredibly difficult, but I noticed I kept writing the same code over and over so came up with this package to make my life easier. Don’t know if I’d go so far as to call it a “framework”, but it’s sort of a loose interpretation of the Adapter design pattern that makes it easy to create groups of buttons with one that remains “down”.
Basically, all you have to do is create a class for your button type that extends MovieClip or Sprite and implements IComplexButton (in the download). All that class does is describe the visual states of your button (up, over and down) and can be as simple or complicated as you’d like. That button class is then “wrapped” in a ComplexButton instance which handles all events. Several of those ComplexButtons are then added to a Menu instance which keeps track of which item is selected and redispatches events so you can add event listeners directly to the menu instance…
Sounds more complicated than it is. All the user has to do is worry about the visual states of their buttons and everything else is taken care of…
I download the example. Upon test it I have this error message :
Warning: 1090: Migration issue: The onMouseDown event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'mouseDown', callback_handler).
The source of this error is from ComplexButton.as line#48, #57, #87, #91, #96, #99, #103, #109, and #113.
A warning is all that is. In AS2 there was a designated event handler named “onMouseDown”. Flash is just trying to be nice and tell you that in AS3 that method no longer exists unless you define it yourself - which that script does. If it really bothers you, you can change the names of the different methods that give you that warning, but it really won’t cause any problems to just ignore it.
I mean, thats just with two buttons more would get complicated but you get what im saying right/
bt down being the overlay your using over the main buttons (1 and 2) to make them appear down
I guess it might over complicate things making the functions alpha based, but thats how i would go about it.
@sekasi - yup… still out there swingin’… I see you’re all over the web as well…
@saxx - as Beebs pointed out, the point of the package is to avoid writing code like that. One of the major selling points of OOP is code reusability… Sure you could write that same thing with minor changes in every project you do, but it’s much nicer to save production time by having it all done for you regardless of what properties you wish to change for selected items…