« [OT] we are 25, UE is growing | Inicio | Atom feed added »

Button handler follow-up

A few weeks ago, I posted about the problem we were having, here at the office, with some buttons.

The feedback was great, but we decided to go on implementing the "solution" we found, just because of the few time we had.

But finally, we've had to make some changes in some buttons that are part of a modal dialog we are building

So, now we have a movieclip with three frames, labeled "normal", "over", and "click". The movieclip contains a textfield named "literal". We want to be able to assign the textfield contents, its format, and the onRelease handler, but we need to set that handler from a different point of the program execution ( I mean, we set the label text when the application initializes, but we set the onRelease handler depending on the execution flow )

So the button handler class is:

class net.designnation.UI.buttonHandler { public static function setBTHandlers( buttonInstance: MovieClip, texto: String ) { buttonInstance[ "textoParam" ] = texto; buttonInstance[ "literal" ].text = texto; buttonInstance.onRollOver = function( ) { this.gotoAndStop( "over" ); var theInstance: String = ""; this[ "literal" ].text = this[ "textoParam" ]; }; buttonInstance.onRollOut = function( texto ) { this.gotoAndStop( "normal" ); this[ "literal" ].text = this[ "textoParam" ]; }; buttonInstance.onPress = function( texto ) { this.gotoAndStop( "click" ); this[ "literal" ].text = this[ "textoParam" ]; }; } public static function setNewTextFormat( buttonInstance: MovieClip, format: TextFormat ) { buttonInstance.literal.setNewTextFormat( format ); } public static function setTextFormat( buttonInstance: MovieClip, format: TextFormat ) { buttonInstance.literal.setTextFormat( format ); } public static function setOnRelease( buttonInstance: MovieClip, value: Function ) { buttonInstance._onRelease = value; buttonInstance.onRelease = function () { this._onRelease( ); this.gotoAndStop( "normal" ); } } }

Have a nice weekend!