PDA

View Full Version : attachMovie


tbuelow
11-21-2002, 05:39 PM
I don't even know where to begin. I want to attach new instances of "Square" so they tile across the page every 50 pixels. I don't want to create this effect in the timeline because it will be to bulky and I have about 84 squares that I want to tile. I was thinking that I could use a for loop, but nothing I try seems to work.

How would you do it?

tg
11-21-2002, 06:50 PM
heres the way i would do it:

goto the movie section at actionscript.org
type 'grid' into the search box
goto the third result (dynamic grid by jesse)
and download the source code.

heh. since i just did it, to find the source, here (http://www.actionscripts.org/showMovie.php?id=39) is the link.

tbuelow
11-21-2002, 07:51 PM
Okay, cool. So now what if I want each square in the grid to appear sequentially starting with the bottom left hand corner over the course of, say, 2 seconds.

tg
11-21-2002, 09:10 PM
like this:

var rows=5; //total number of rows
var cols=5; //total number of cols
var r=rows; //value for current (beginning) row
var c=0; //value for current (beginning) row
var counter=0; //counter to keep all the levels/depths sorted.

makeSquare=function(){
//create your mc
grid=this.createEmptyMovieClip("box"+(counter++),counter);
//set up all the pretty stuff to make it look the way you want.
grid.lineStyle(0,0x000000,100);
grid.beginFill(0x888ccc,100);
grid.moveTo(0,0);
grid.lineTo(0,20);
grid.lineTo(20,20);
grid.lineTo(20,0);
grid.lineTo(0,0);
grid.endFill();
//return the mc
return grid;
};

addGrid=function(){
//trace("make grid "+c+":"+r); //test to see positioning
/*
make the sqaure by calling the function.
you could replace this easily by using attach movie clip action
*/
g=makeSquare();
//position the mc
g._x=(g._width)*c;
g._y=(g._height)*r;
//adjust the next position values.
c++;
if(c==cols){
c=0;
r--;
if(r==0)clearInterval(id);
}
};
//use set interval to control your time... this is set for 100 milliseconds.
//change this to 1000 for 1 second.
id=setInterval(addGrid,1000);



if your not sure how this works, copy and paste into flash and play around with it some.