Make one subclass that handles both HTML and multiline? From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of wnoone01 Sent: Thursday, September 11, 2008 11:17 AM To: [email protected] Subject: [flexcoders] Subclassing Components: Theoretical Question
Hey all, I've got a theoretical question about subclassing a component. Here is the use case: A programmer requires buttons that support multiline labels. This is a requiement for Button, RadioButton, and CheckBox. Now to start, the programmer can subclass mx.controls.Button to implement the functionality. But now he needs to implement the functionality in RadioButton and CheckBox. One way is to subclass RadioButton and CheckBox and then duplicate the functionality there. However, not only will he be duplicating functionality, he is headed down a slippery slope. Let's say that for his next project, he suddenly requires a button label that supports HTML formatting. Now he must subclass again. So now the classes grow from: MultilineButton MultilineRadioButton MultilineCheckBox To MultilineButton HTMLButton MultilineRadioButton HTMLRadioButton MultilineCheckBox HTMLCheckBox The next project requires a multiline html button. So now its: MultilineButton HTMLButton MultilineHTMLButton MultilineRadioButton HTMLRadioButton MultilineHTMLRadioButton MultilineCheckBox HTMLCheckBox MultilineHTMLCheckBox And now its officially out of hand and the programmer is mired in a subclassing nightmare. --- So basically my question is what is the best way to handle this problem in Flex. Is subclassing the only way or is there a more efficient solution (decorators, item renderers, etc.)? Thanks in advance for any guidance Bill

