Actually, a lot of folks have asked this kind of question.  We did a 
lot of work to document MXML components which are great ways of 
making new components that comprise other components, and we did 
document AS Components in several places like Flex Explorer and the 
LiveDocs.  However, it still can be hard to get your head around AS 
Components because there's way too many use cases to document and the 
one you want isn't doc'd.

The essence of what you want to do is this (no guarantees that this 
works as is, some fiddling may be required):

JamieTextInput.as
class JamieTextInput extends mx.controls.TextInput
{
  function set text(s)
  {
    if (s == null)
        s = "";
    super.text = s;
  }
}

JamieApp.MXML
<mx:Application xmlns="*" ...>
  <JamieTextInput text={whatever}...>

By extending TextInput you can override the text setter, alter the 
input value if necessary then pass it on to the base class

Then you use that class instead of mx:TextInput in your application.

--- In [email protected], "jamiebadman" <[EMAIL PROTECTED]> 
wrote:
> --- In [email protected], "alex_harui" <[EMAIL PROTECTED]> wrote:
> > The TextInput is kind enough to do a toString() on anything 
passed 
> to 
> > its .text property, which is great for Number and other things, 
but 
> > is the root of your problem.
> > 
> > My advice, subclass TextInput and put the null check on the text 
> > setter.
> > 
> > -Alex
> 
> Hi,
> 
> At the risk of sounding stupid (well it's painfully obvious to be 
> honest ;-) )...
> 
> I've scoured for a good example of how to do this subclassing and 
> can't find anything. There's an article on the Macromedia site 
> called 'A Primer for Building Flex Applications' that seems to 
> *almost* help - but the example doesn't go so far as actually 
> explaining how the subclass is used/referenced.
> 
> Can anyone point me somewhere that contains a good example of 
> subclassing that I might be able to learn from ?
> 
> Thanks,
> 
> Jamie.




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to