-
Actionscript 3, postproduction
[CS3]Any ideas to instantiate library symbols dynamically?
In Flash 8 I used dynamic linkages to instantiate symbols quite often, i.e. / 'symbol_'+i / can load ordered linkage symbols for 'symbol_0', 'symbol_1', 'symbol_2'...
Now in Flash CS3, no linkage any more but they have to be a class name such as 'TreeHouse_0' class for a 'Tree House 0' symbol. They can not be instantiated with / new ['TreeHouse_'+i]() / or so. Any one have some ideas?
Thanks.
-
Senior Member
Here is an example. You can give variable names.
for (var count:int = 0; count <= 10; count++)
{
var myVar:MovieClip = new MovieClip ();
myVar.name = "myVar_"+count02;
myVar.y = count02*myVar.height;
this.addChild (myVar);
}
- The right of the People to create Flash movies shall not be infringed. -
-
Actionscript 3, postproduction
Thanks Cancerinform. Though I'm looking for idea of dynamic 'linkage' (custom class in CS3) but not dynamic instance name.
For example in AS2, it was:
var i:Number;
for(i=0; i<10; i++)
this.attachMovie("symbol_"+i, "s"+i, this.getNextHighestDepth());
In CS3 the first parameter is changed to a class name which cannot create dynamically. But to do this way it sucks:
var s0=new symbol_0();
s0.name = 's0';
var s1=new symbol_1();
s1.name = 's1';
...
-
Hi, I had a similar problem and I solved it using code similar to this. I hope it helps.
var classReference:Class = getDefinitionByName("symbol_"+i) as Class;
var newClip:MovieClip = new classReference()
stage.addChild(newClip)
-
Actionscript 3, postproduction
Good point. Thanks Cortana.
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
|