Topic: Can you enumerate components in Actionscript

Hi,
can anyone advise on enumeration i actionscript. As an example - I have a widget with lots of components that are similar e.g. progress bars called day1, day2, day3 ... I spend a lot of time repeating the same statements (ugly code0 such as
day1.color =
day2.color =
etc.

In some languages that support object models with strong hierachies eg Delphi this could be replaced by something like

for i = 1 to form.components.componentcount
  if form.component[i].name begins "day" then
    form.component[i].color = ...

Is there any way this can be done or are there alternatvies e.g. it looks like actionscrio is compiled so could I build the component names as strings eg

for i = 1 to 7
  name = "day" + string(i)
  name.color = ...

cheers and thansk in advance.

Nigel

smile smile smile

Re: Can you enumerate components in Actionscript

Hi,

I'm not quite familiar with actionscript but read enough ActionScript vs HaXe documentation to note that there are arrays in ActionScript as well.

Perhaps create an array of the components?  e.g. Array of MovieClips like :-

Cheers,
M

Re: Can you enumerate components in Actionscript

Madox wrote:

Hi,

I'm not quite familiar with actionscript but read enough ActionScript vs HaXe documentation to note that there are arrays in ActionScript as well.

Perhaps create an array of the components?  e.g. Array of MovieClips like :-

Cheers,
M

Madox,
thanks for the feedback but previous reading suggests that Actiobscript only support arrays for simple types (String and Number).

Cheers Anyhow 

Nigel

smile smile smile

Re: Can you enumerate components in Actionscript

http://www.actionscript.org/forums/show … 3?p=430637

Re: Can you enumerate components in Actionscript

Madox,
             ah - thats oh so sweet - thanks.

cheers

Nigel


  smile  smile  smile

Re: Can you enumerate components in Actionscript

you can do, for example:

eval("_parent.main_mc.item"+i+"_mc")._x = N;

Re: Can you enumerate components in Actionscript

theMartix wrote:

you can do, for example:

eval("_parent.main_mc.item"+i+"_mc")._x = N;

theMartix,
           Thanks - looks like this["some object name"]. solves all my problems.

cheers

Nigel

  smile   smile   smile

Re: Can you enumerate components in Actionscript

Yes, I think its almost the same.