|
-
[RESOLVED] Dynamic access of object properties
(continued from this thread)
I'm looking for a clean way to set an object's properties without knowing ahead of time what kind of object it is or what the properties will be. For example, the object may be a VBox or HBox, in which case I will be setting height, width, border effects, etc, or it may be a TextField, in which case I will be setting font, fontsize, etc.
I could spend lines and lines of code defining what properties to expect for what objects (not looking forward to that), but I was wondering if there is a dynamic way to handle this. For example, the XML object has an attribute array that contains the attribute names and values for a particular node. You can use the following to dynamically set those attributes:
Code:
myXML["id"] = "node1";
Is there something similar for objects, i.e.:
Code:
myVBox["height"] = 150;
?
Last edited by Upchurch; 08-09-2007 at 10:50 AM.
-
half as fun, double the price
myVBox["height"] = 150; will work if a) myVBox has the height property or b) myVBox (VBox?) is a dynamic class.
-
 Originally Posted by senocular
myVBox["height"] = 150; will work if a) myVBox has the height property or b) myVBox (VBox?) is a dynamic class.
You're kidding me. It's just that simple? I assumed it wouldn't be since I didn't see any documentation that talked about that method of property access. That is way too cool.
Just to verify:
myVBox.height is equivalent to myVBox["height"]?
( where var myVBox:VBox = new VBox() )
-
half as fun, double the price
-
Damn you, Easily Accessible Information!
(thanks)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|