PDA

View Full Version : Extend Button Componenet


kvarga
11-22-2005, 03:36 PM
Hello,


I am trying to extend the Button component that comes with Flash 8. I
had been successful until I tried to change the font size of the label
and extend the onPress, onRelease and onReleaseOutside.


1. Font Size - here is my action script that I am using.
[Inspectable(defaultValue=24)]
public function set fontSize(fsize:Number)
{
this.setStyle("fontSize",fsize);
}


2. How do you extend an event? When I do the following the event stops
firing.
function onPress = function()
{
// my code
}


Any help on either of these issue would be appreciated.

Thanks,
Kevin

Scottae
11-22-2005, 04:30 PM
You are only going to see the font size change at runtime. The setStyle method has no effect during author time.
Components use event listeners (http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002983.html) to deal with things such as button events. See the EventDispatcher (http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003473.html) API for more details. Also take a look at mx.controls.SimpleButton class. Search for the dispatchEvent({type:"click"});


Why do you want to extend the Button class? I try to avoid using the UI Components that come with Flash if possible. Maybe try building your own component (http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003016.html).

kvarga
11-22-2005, 04:34 PM
Thanks for your reply.

My problem with the fontSize is that it is not changing at runtime.

I will take a look at the EventDispatch API.

Thanks,
Kevin