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
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of alpharythms
Sent: Thursday, April 06, 2006 10:34 AM
To: [email protected]
Subject: [flexcoders] What is the best way to add a variable to a
component that already exist?
Is there way to dynamically extend a component instance that is
already created?
Basically I want to to store a couple additional properties in a
component. I know that I can create an extended class that will work
if I create the component from it.
However is there a way to do this dynamically. At runtime could I
take a TextInput placed in the layout, Type it to TextInputSpecial and
then add my new properties/variables?
Thanks,
Adam
--
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/