On 9/1/07, [p e r c e p t i c o n] <[EMAIL PROTECTED]> wrote:
> greetings experts!
>
> way back in the days of as2 you could do something like this...
>
> this["somevarname"+someIndex] = new Something();

Even in AS2, it seems that this would be better done with an array.

var somethings:Array = [];
something[someIndex] = new Something();

(Same syntax in AS3.)

Come to think of it, even in AS1 it would be better done with an
array. The last time I would have used such a structure was in Flash 4
Actions.

One exception might be for MovieClip/Button/TextField instances in
AS2. Often in AS2 it was handy to grab those by their name, since they
are often made through the IDE rather than through code. The new way
of retrieving a composed display object by its name is the
getChildByName() function of the DisplayObjectContainer class (which
Sprite, among others, extends). So you could do something like this
within some class that extends DisplayObjectContainer:

var currentObject:DisplayObject = getChildByName("someVarName" + someIndex);

I'm still not sure if that would be the most elegant solution in most
situations, though. It still seems to me that in most cases an array
should be somehow involved.

-- 
Mike Keesey
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to