FORUMS: list search recent posts

[AS3] dynamically referencing object names

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
tom custer
[AS3] dynamically referencing object names
on Nov 20, 2008 at 7:46:42 pm

I come from a Lingo - AS2 scripting background and am trying to get a handle on AS3 and how it uses classes.

I've always relied on concatenating strings to reference a series of objects.
I've exported a series of movie clips as classes and want to reference them in the document class.
The following works as expected.
var _ballname:*;
_ballname = new SLD_5;
mcP1.setType(_ballname); // is another class method


But I like to use a 'for' loop to create the series of 15 movies cause it's easier to make changes. When I try to put the above in a for loop with something like
for (var i:Number = 1; i < 15; i++)
{
_ballname =("SLD_" + i);
trace (_ballname);
_balltype = new (_ballname)();

("mcP" + i).setType(_balltype);

}
I get errors like "Instantiation attempted on a non-constructor " where ever I try use the concatenated string.
Sorry this is so long. Thanks for taking time to read.


Tom Karl


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]