PDA

View Full Version : Dynamic MovieClipClip Instances


matt.bull
07-21-2002, 07:06 PM
Firstly.. Hello!

I've only just found this site and the tutorials and advice are very handy indeed!

I've only been using flash for about 3 days and have hit a problem when trying to generate movieclips on the fly.

I'm not sure if I'm even going about this the correct way and would be grateful of any advice you could provide :O)

At the moment I'm trying to get a map populated with a (variable) number of buttons. The only thing that seems to be working at the moment is the array holding the number of buttons and their positions.. I'm basically doing this..

myNumberButtons = mySites.length;
myCoords = Array();
myMCs = Array();
for (i=0; i < myNumberButtons; i++) {
_root.greenbutton.createEmptyMovieClip(_root.myMCs[i], 0);
_root.myMCs[i].attachMovie(greenbutton, "greenbutton" + i, 0);
_root.myCoords = _root.myMapCoords[i].split(";");
_root.myMCs[i]._x = _root.myCoords[0];
_root.myMCs[i]._y = _root.myCoords[1];
_root.myMCs[i]._visible = true;
}

where mysites is ("a","b","c","d") and myMapCoords is ("10;20","35;40","40;50") etc...

After running this and debugging the myMCs array just never seems to get populated.

If someone could shed some light on where this is going wrong ( in my thinking :O) I'd be grateful!

If there is a more correct way to do this then please do tell!

Thanks in advance,

Matt

xxlm
07-21-2002, 07:22 PM
First, you use same name for multiple object (here array and Movie clip)... Not really good. Second you use createEmptyMovieClip, but don't need to use it...


myNumberButtons = mySites.length;
myMapCoords = Array("10;20","35;40","40;50");
myCoords = Array();
for (i=0; i < myNumberButtons; i++) {
_root.attachMovie("greenbutton", "greenbutton" + i, i);
_root.myCoords = _root.myMapCoords[i].split(";");
_root["greenbutton"+i]._x = _root.myCoords[0];
_root["greenbutton"+i]._y = _root.myCoords[1];
_root["greenbutton"+i]._visible = true;
}


May work...

matt.bull
07-21-2002, 07:56 PM
Thanks xxlm!

I can now see the objects being instantiated in the debugger, they're still not being displayed though.. but that's something else :O)

Cheers!

xxlm
07-22-2002, 05:14 AM
:) :p :D