Groups | Blog | Home
all groups > flash actionscript > april 2005 >

flash actionscript : Need Advice: Extending components


Novian
4/6/2005 9:40:12 PM
Hi there, I want to add some functionality to a MX 2004 component. I'm
evaluating whether or not I should create my own component from scratch or
simply (if it is in fact simple) add a new method to an existing component.
Any advice, links to articles/tutorials would be greatly appreciated. Thanks.
bobpf
4/6/2005 9:46:00 PM
Novian
4/6/2005 11:08:24 PM
Hi bobpf, Could you elaborate on what you mean by 'composes', please? Thanks.
Also, the third party component is actually a MM component -- in this case the
dateChooser component. I appreciate your help.
Novian
5/18/2005 8:27:17 PM
Back again. Same issue but with a little more knowledge behind me.

What I want to do is to extend an MX 2004 component, in this case the
DateChooser. I think all I need to do is add a new method to the DateChooser.as
and recompile the component. The thing is, I'm reading that most developers
prefer to create a new component altogether by extending the classes used by
the MX 2004 component they are trying to extend. This seems kind of overkill if
you can just add a few lines of code to the original class and
recompile....unless of course I am missing something. Am I missing something?

Thanks.
mpetty
5/19/2005 12:27:04 AM
by no means is it overkill, in fact it's simply good practice. Here's why: in
team oriented development, you avoid costly mistakes of possible error
introduction, helps to enforce a "is-a" or "uses-a" relationships, and it
promotes the king of all OOP mantra's: reuse.

If you have additional methods for a date chooser, you can go one of two ways
1. write a new class mynewdatechooser extends datechooser, or
2. write a class which uses the datechooser component but uses the method as a
callback to an event change

Also note, you won't actually be able to change the datechooser class in your
local directory and have it work directly. all mm components are swc's which
means they have already been compiled once and stay that way (strict version
control). however, you could in theory delete/rename the datechooser swc,
change the class, recompile back to a swc, export to the default directory, and
reboot flash.... but that's playing with fire while soaked in gasoline, simply
not a good idea.
Novian
5/19/2005 6:27:17 PM
Hi mpetty,

Thanks so much for the advice. I had a feeling this was the case. I'll remember the OOP mantra: "Reuse!!!"

Thanks again.

AddThis Social Bookmark Button