Sorry, if an object is an instance of a class, it can't be changed at
runtime to be an instance of a different class.

I think you could make a <mx:TextInput> tag produce a TextInputSpecial
instance by editing the mxml-manifest.xml file which maps MXML tags to
AS classes, but this would be confusing and I don't recommend it.

You can, however, create your own namespace with its own manifest so
that you can write

    <special:TextInput>

and map it to TextInputSpecial.

Or you can call your subclass TextInput instead of TextInputSpecial and
it will be distinct from ours because it will be in a separate package.
You should be able to do something like

    package special
    {
        import mx.controls.TextInput;

        public class special.TextInput extends mx.controls.TextInput
        {
            ...
        }
    }

- Gordon


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of alpharythms
Sent: Thursday, April 06, 2006 1:07 PM
To: [email protected]
Subject: [flexcoders] Re: What is the best way to add a variable to a
component that already exist?

Thanks Gordon,

Is there a way to turn a TextInput into a TextInputSpecial at runtime?
 Or a way to say all <mx:TextInput ..> tags use instances of
TextInputSpecial instead?

Initially I wanted to have some variables available in a change
handler so I could pull it out by event.target.myExtraStuff, but I
ended up dynamically creating the event.CHANGE functions to include
the data I need.  

I'm still curious if it is possible to dynamically re-type something
at runtime.  The only way I could see it working if the new type is an
extened class of the orginal.  I imagine you can't do this... 


Thanks again,
Adam

--- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> The Flex component classes like TextInput aren't dynamic, so you can't
> add any properties to them that aren't declared at compile time.
> 
> However, if you create a dynamic subclass
> 
>     public dynamic class TextInputSpecial extends TextInput
>     {
>         ...
>     }
> 
> you should be able to add anything you want at runtime:
> 
> 
>     myTextInputSpecial.foo = "bar";
> 
> Alternately, you can make a non-dynamic subclass which has an Object
var
> to which you can add things dynamically, because the Object class is
> dynamic:
> 
>     public class TextInputSpecial extends TextInput
>     {
>         var extraStuff:Object = {};
>         ...
>     }
> 
>     myTextInputSpecial.extraStuff.foo = "bar:
> 
> - Gordon
> 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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