I do ActionScript 3.0 programming and I know that very well. I have a project with ActionScript 2.0 and I got a simple problem for adding instances to the stage. In ActionScript 3.0 when I want to add multiple instances to some Movie Clip, first I save them in an array and then I work with that array to set X and Y and width and alpha and other details.
example:
” itemBlock ” is my instance which is an exported movieclip in library.
for ( var i = 0 ; i < 24 ; i++ ) {
blockBANK[i] = new itemBlock(); // itemBlock is an exported movieclip in the library.
blockBANK[i].x = // some calculation;
blockBANK[i].y = // some other calculation;
mainPage_mc.addChild(blockBANK[i]); // add to the mainPage_mc holder
}
and now I can use this array to add and edit my instance everywhere in my AS3 code.
In AS2 I try these but not working and also NO compiler error !
for (var i=0;i<7;i++) {
var temp:MovieClip = new MovieClip();
temp.attachMovie("itemBlock "," itemBlock "+i,0);
textboxBANK[i].addChild(temp);
textboxBANK[i]._y = 40;
textboxBANK[i]._x = i * 20;
mainPage_mc.addChild(textboxBANK[i]);// add to holder
}
not working and no compiler error
for (var i=0;i<7;i++) {
var temp:MovieClip = new MovieClip();
temp.attachMovie("itemBlock","itemBlock"+i,0);
textboxBANK[i].attachMovie(temp);
textboxBANK[i]._y = 40;
textboxBANK[i]._x = i * 20;
mainPage_mc.attachMovie(textboxBANK[i]);// add to holder
}
not working again and no compiler error ..
How I put instances in an array and add them to a holder FROM that array in AS2 ?
As far as I know, you create a new MovieClip in AS2 using the createEmptyMovieClip method. Also, the addChild method is not supported in AS2.
The AS2 display list is quite different from the AS3 one. A display object only exists when it is on the stage (unlike AS3, where you can traverse the display tree with a stored DisplayObject). In short, if you’re trying to store MovieClips in an array, to add to the stage later, it isn’t possible.
What you’ll need to do is add them to the stage, and mess with their *_visible* property. Then make them visible at a later stage. Here’s some code, based on what I understand you to be wanting to do…
Be aware that, in AS2, if you try and add something to the stage at the same depth, the original display object will disappear. Use the getNextHighestDepth method to exact the correct integer.
A much better description of what you’re trying to do would be very helpful.