The bracket notation should work.  Use a var to get a ref to the object
you want first, inspect csome properties via the reference to be sure is
is valid, then set your properties.

 

var oTemp:Object = this["H" + i];

trace (oTemp.id)

oTemp.width = iWidth;

 

Tracy

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of chigwell23
Sent: Sunday, April 27, 2008 1:51 AM
To: [email protected]
Subject: [flexcoders] Re: still having trouble assembling Flex property
assignments from string calcs

 

Thanks for the responses - (missed quotes was in my example not code
:-)) - what I need to do generically is communicate with Flex objects
and their properties by constructing their ids etc.

My example was for a degrafa UI instance of class Surface, which has a
child of fill221 which has a property of color, which might have been
too convoluted an explanation .... say I have 5 HBoxes in a Canvas,
with ids of H1, H2,H3,H4, H4. 

in a script block I can

H1.width = 100; // standard coding

Pseudocode:

["H" + var1].width = 100 // var1 = 1 and the concatenation creates id
H1, setting its width to 100

Thus in a loop of 1 to 5, one could use the value of i

["H" + i].width to set the width of the 5 HBoxes

TIA,

Mic.

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> I don't know if he's using non-UIComponents or not.
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Tracy Spratt
> Sent: Friday, April 25, 2008 11:06 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] still having trouble assembling Flex
property
> assignments from string calcs
> 
> 
> 
> I am a bit surprised the assignment works. I was under the impression
> that for styles, we needed to use setStyle().
> 
> Tracy
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Alex Harui
> Sent: Friday, April 25, 2008 1:37 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] still having trouble assembling Flex
property
> assignments from string calcs
> 
> 
> 
> You don't have quotes around #FF0000.
> 
> 
> 
> It would help if you tell us what problem occurs when you do this.
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of chigwell23
> Sent: Friday, April 25, 2008 12:01 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] still having trouble assembling Flex property
> assignments from string calcs
> 
> 
> 
> testSurface.fill221.color = "#FF0000"; //works
> 
> testSurface.["fill" + fillNo].color = #FF0000 // fillNo = 221
> 
> is what I would do in another life :-) ... could someone set me on the
> straight and narrow? TIA,
> 
> Mic.
>

 

Reply via email to