Creating Empty MC and Grids


_root.createEmptyMovieClip('dot', 1)
dot.lineStyle(.5,000000,100)
dot.beginFill(778833,100)
dot.lineTo(15,0)
dot.lineTo(15,15)
dot.lineTo(0,15)
dot.lineTo(0,0)
dot.endFill()
gridX=30;
gridY=30;
nNum=0;
for (var ii=0;ii < 10;ii++) {
  for (var jj=0;jj < 10;jj++) {
   dot.duplicateMovieClip("dot"+nNum,nNum);
    mc=_root["dot"+nNum];
    mc._x=gridX*ii;
    mc._y=gridY*jj;
    nNum++;
  }
}

This just creates a movieclip that is a square, but when I try to duplicate it, it doesn’t work. The Original MC is on the stage, but the grid doesn’t show up, also, the statement

dot._visible = 0

Doesn’t work, but

dot._alpha = 0

does work…I’m confuzzled…any ideas?

Try dot._visible = 0.

EDIT: Sorry - I just noticed something - so I deleted what I wrote earlier. I haven’t had a chance to look at the code properly yet, holding my little boy :slight_smile:

Yeah, I know dot._visible = 0

That didn’t work. It was just a typo in my post…

I had the same problem! It works if you draw the object and give it the instance name. But if you dynamically create it and give it an instance name, it will not work.

Ilyas did it dynamically, but he removed the source code from his entry so I can’t see how he did it.

Why don’t you create the first tile then use attachMovie - this is what I did here:

Unless there’s a reason you specifically want to use an empty mc and duplicateMovieClip

It is fun trying to come up with something you can make purely out of AS without anything in the library.

Ah, ok.

Is there any benefit for it? I would understand if it saved processing power, etc. but if it’s not usable - I don’t use it.

But if you want to explore the dynamic possibilities of Flash - then that’s different…

I’m just messing around really. I was just trying to teach myself lineTo and beginFill and all that fun stuff…just wondering why it wasn’t working…

Well I am supposing in this case it is for the AS contest…haha.

I do believe it saves on loading time/file size because it does not require the loading of the graphics. And being that the AS contest requires a small file size this really would help.

Also, I just want to figure it out because it is being such a pain and I dont know why.

Ok. I was comparing to to attaching tiles in my example. Compared the way I did it, to this dynamic way - it would hardly save anything since a square of 10 x 10 pixels, wouldn’t but that processor intensive, especially since he whole swf (3) tiles is only around 300 bytes (not even 1 KB)!

But in other ways it might save some of your pc’s life span. But all depends how complex a graphic you can create dynamically with lineStyle, etc.

Anyway - you guys are actionscript junkies so I’ll leave you to it!

_root.createEmptyMovieClip(‘dot’, 1)
dot.lineStyle(.5,000000,100)
dot.beginFill(778833,100)
dot.lineTo(15,0)
dot.lineTo(15,15)
dot.lineTo(0,15)
dot.lineTo(0,0)
dot.endFill()
gridX=30;
gridY=30;

for (var ii=0;ii < 10;ii++) {
for (var jj=0;jj < 10;jj++) {
dot.duplicateMovieClip(“dot”+nNum,nNum);
mc=_root[“dot”+nNum];
mc._x=gridXii;
mc._y=gridY
jj;
nNum++;
}
}

Just took out the nNum = 0;

lol, that makes no sense whatsoever!!

My post or the fact the I just took out the nNum = 0?

Aha! Common problem when you use the drawing API…

Hint: Someone recently asked me why I created my empty clips at negative depths… Well that’s why.

pom :asian:

I think because when you say nNum++ you mean, 1, ie. 1 more tha 0 - which is root, but if you specifically say nNum = 0, then load the first dup into 0 - it will load over the first. Just a guess…

Hey? You weren’t here when I was typing my post. How’d you sneek in?

:stuck_out_tongue:

But that nNum thing is strange…