Link to home
Start Free TrialLog in
Avatar of zahimezher
zahimezher

asked on

Duplicate Movie CLip AS2

I have a script that is supposed to repeat a mc on the stage so that the movie clip itself is repeated to cover the entire width of the stage using duplicateMovieClip();

I tried placing the script in a function so that when the window is streched teh movie clip will be duplicated more and never stop ,,,,

Not Workin :(

The Mc instance name = tile
AS = On the frame
stop();

Stage.scaleMode = "noScale";

tile._visible = false;

// enter how many rows and columsn you want? 

rows = 1;
columns = Stage.width / tile._width ;

// starting positions of your first tile sx

xpos = 0;
ypos = 109;

// spacing between each tile 

vspace = 3;
hspace = 3;

// the width and height of your tile mc 

wclip = tile._width;
hclip = tile._height;

// our counter 

theclip = 1;

// make our grid 

/*
for (var i = 0; i<rows; i++) {
	for (var j = 0; j<columns; j++) {

		var thematrix = tile.duplicateMovieClip("tile"+theclip, theclip+1);

		thematrix._x = xpos+((wclip+hspace)*j);
		thematrix._y = ypos+((hclip+vspace)*i);
		theclip++;
	}
}

*/




function resizematrix() {
	for (var i = 0; i<rows; i++) {
		for (var j = 0; j<columns; j++) {

			var thematrix = tile.duplicateMovieClip("tile"+theclip, theclip+1);

			thematrix._x = xpos+((wclip+hspace)*j);
			thematrix._y = ypos+((hclip+vspace)*i);
			theclip++;
		}
	}
}


resizematrix();


var resizeListener:Object = new Object();
Stage.addListener(resizeListener);

resizeListener.onResize = function() {

	resizematrix();

};

Open in new window

Avatar of zahimezher
zahimezher

ASKER

Im using an image in the MC so I dont want to strech teh pic that why Im doin this ! :S
I think you need to recalculate the columns and rows whenever the size of the stage get resized...  Just move those lines that calculate them into the resizematrix() function to get the new value...

CyanBlue
Ok I did that but still its doesnt recreate new tiles when teh stage is resized :S
stop();

Stage.scaleMode = "noScale";

tile._visible = false;

// enter how many rows and columsn you want? 

rows = 1;
columns = Stage.width / tile._width ;

// starting positions of your first tile sx

xpos = 0;
ypos = 109;

// spacing between each tile 

vspace = 3;
hspace = 3;

// the width and height of your tile mc 

wclip = tile._width;
hclip = tile._height;

// our counter 

theclip = 1;

// make our grid 




function resizematrix() {
	for (var i = 0; i<rows; i++) {
		for (var j = 0; j<columns; j++) {

			var thematrix = tile.duplicateMovieClip("tile"+theclip, theclip+1);

			thematrix._x = xpos+((wclip+hspace)*j);
			thematrix._y = ypos+((hclip+vspace)*i);
			theclip++;
		}
	}
}


resizematrix();


var resizeListener:Object = new Object();
Stage.addListener(resizeListener);

resizeListener.onResize = function() {

	resizematrix();

};

Open in new window

I don't see you doing what I said...  I meant that you need to copy line 9 & 10 that say rows = 1 and columns = ... into the resizematrix() function right before the beginning of the for loop...

See if that works...  If not, post the updated code...

CyanBlue
Im guessing it worked but im not sure cause when i resized the window the first one moved to the center of the stage and didnt stay at xpos = 0;  

Please keep in mind that I cant use (Stage.align = "TL")

Thanx
stop();

Stage.scaleMode = "noScale";

tile._visible = false;

// enter how many rows and columsn you want? 

rows = 1;
columns = Stage.width / tile._width ;

// starting positions of your first tile sx

xpos = 0;
ypos = 109;

// spacing between each tile 

vspace = 3;
hspace = 3;

// the width and height of your tile mc 

wclip = tile._width;
hclip = tile._height;

// our counter 

theclip = 1;

// make our grid 




function resizematrix() {
	rows = 1;
columns = Stage.width / tile._width ;
	
	
	for (var i = 0; i<rows; i++) {
		for (var j = 0; j<columns; j++) {

			var thematrix = tile.duplicateMovieClip("tile"+theclip, theclip+1);

			thematrix._x = xpos+((wclip+hspace)*j);
			thematrix._y = ypos+((hclip+vspace)*i);
			theclip++;
		}
	}
}


resizematrix();


var resizeListener:Object = new Object();
Stage.addListener(resizeListener);

resizeListener.onResize = function() {

	resizematrix();

};

Open in new window

Can you trace the thematrix._x and thematrix._y inside the for loop and paste it here???

CyanBlue
i have no idea what that means :(
Sry but Im a beginer at this ! The script I pasted b4 "Found on google"
Replace your function be like this, do test movie, resize the stage size and paste the values from the Output panel into the post so that I can see it...  ;)

CyanBlue
function resizematrix() {
	rows = 1;
	columns = Stage.width / tile._width ;

	for (var i = 0; i<rows; i++) {
		for (var j = 0; j<columns; j++) {
			var thematrix = tile.duplicateMovieClip("tile"+theclip, theclip+1);
			thematrix._x = xpos+((wclip+hspace)*j);
			thematrix._y = ypos+((hclip+vspace)*i);
			theclip++;
			trace("thematrix : " + thematrix._x + " / " + thematrix._y + " : " + "Stage = " + Stage.width + " / " + Stage.height);
		}
	}
}

Open in new window

thematrix : 0 / 109 : Stage = 900 / 650
thematrix : 64 / 109 : Stage = 900 / 650
thematrix : 128 / 109 : Stage = 900 / 650
thematrix : 192 / 109 : Stage = 900 / 650
thematrix : 256 / 109 : Stage = 900 / 650
thematrix : 320 / 109 : Stage = 900 / 650
thematrix : 384 / 109 : Stage = 900 / 650
thematrix : 448 / 109 : Stage = 900 / 650
thematrix : 512 / 109 : Stage = 900 / 650
thematrix : 576 / 109 : Stage = 900 / 650
thematrix : 640 / 109 : Stage = 900 / 650
thematrix : 704 / 109 : Stage = 900 / 650
thematrix : 768 / 109 : Stage = 900 / 650
thematrix : 832 / 109 : Stage = 900 / 650
thematrix : 896 / 109 : Stage = 900 / 650
thematrix : 0 / 109 : Stage = 901 / 650
thematrix : 64 / 109 : Stage = 901 / 650
thematrix : 128 / 109 : Stage = 901 / 650
thematrix : 192 / 109 : Stage = 901 / 650
thematrix : 256 / 109 : Stage = 901 / 650
thematrix : 320 / 109 : Stage = 901 / 650
thematrix : 384 / 109 : Stage = 901 / 650
thematrix : 448 / 109 : Stage = 901 / 650
thematrix : 512 / 109 : Stage = 901 / 650
thematrix : 576 / 109 : Stage = 901 / 650
thematrix : 640 / 109 : Stage = 901 / 650
thematrix : 704 / 109 : Stage = 901 / 650
thematrix : 768 / 109 : Stage = 901 / 650
thematrix : 832 / 109 : Stage = 901 / 650
thematrix : 896 / 109 : Stage = 901 / 650
thematrix : 0 / 109 : Stage = 905 / 650
thematrix : 64 / 109 : Stage = 905 / 650
thematrix : 128 / 109 : Stage = 905 / 650
thematrix : 192 / 109 : Stage = 905 / 650
thematrix : 256 / 109 : Stage = 905 / 650
thematrix : 320 / 109 : Stage = 905 / 650
thematrix : 384 / 109 : Stage = 905 / 650
thematrix : 448 / 109 : Stage = 905 / 650
thematrix : 512 / 109 : Stage = 905 / 650
thematrix : 576 / 109 : Stage = 905 / 650
thematrix : 640 / 109 : Stage = 905 / 650
thematrix : 704 / 109 : Stage = 905 / 650
thematrix : 768 / 109 : Stage = 905 / 650
thematrix : 832 / 109 : Stage = 905 / 650
thematrix : 896 / 109 : Stage = 905 / 650
thematrix : 0 / 109 : Stage = 940 / 660
thematrix : 64 / 109 : Stage = 940 / 660
thematrix : 128 / 109 : Stage = 940 / 660
thematrix : 192 / 109 : Stage = 940 / 660
thematrix : 256 / 109 : Stage = 940 / 660
thematrix : 320 / 109 : Stage = 940 / 660
thematrix : 384 / 109 : Stage = 940 / 660
thematrix : 448 / 109 : Stage = 940 / 660
thematrix : 512 / 109 : Stage = 940 / 660
thematrix : 576 / 109 : Stage = 940 / 660
thematrix : 640 / 109 : Stage = 940 / 660
thematrix : 704 / 109 : Stage = 940 / 660
thematrix : 768 / 109 : Stage = 940 / 660
thematrix : 832 / 109 : Stage = 940 / 660
thematrix : 896 / 109 : Stage = 940 / 660
thematrix : 960 / 109 : Stage = 940 / 660
thematrix : 0 / 109 : Stage = 986 / 673
thematrix : 64 / 109 : Stage = 986 / 673
thematrix : 128 / 109 : Stage = 986 / 673
thematrix : 192 / 109 : Stage = 986 / 673
thematrix : 256 / 109 : Stage = 986 / 673
thematrix : 320 / 109 : Stage = 986 / 673
thematrix : 384 / 109 : Stage = 986 / 673
thematrix : 448 / 109 : Stage = 986 / 673
thematrix : 512 / 109 : Stage = 986 / 673
thematrix : 576 / 109 : Stage = 986 / 673
thematrix : 640 / 109 : Stage = 986 / 673
thematrix : 704 / 109 : Stage = 986 / 673
thematrix : 768 / 109 : Stage = 986 / 673
thematrix : 832 / 109 : Stage = 986 / 673
thematrix : 896 / 109 : Stage = 986 / 673
thematrix : 960 / 109 : Stage = 986 / 673
thematrix : 1024 / 109 : Stage = 986 / 673
thematrix : 0 / 109 : Stage = 1054 / 694
thematrix : 64 / 109 : Stage = 1054 / 694
thematrix : 128 / 109 : Stage = 1054 / 694
thematrix : 192 / 109 : Stage = 1054 / 694
thematrix : 256 / 109 : Stage = 1054 / 694
thematrix : 320 / 109 : Stage = 1054 / 694
thematrix : 384 / 109 : Stage = 1054 / 694
thematrix : 448 / 109 : Stage = 1054 / 694
thematrix : 512 / 109 : Stage = 1054 / 694
thematrix : 576 / 109 : Stage = 1054 / 694
thematrix : 640 / 109 : Stage = 1054 / 694
thematrix : 704 / 109 : Stage = 1054 / 694
thematrix : 768 / 109 : Stage = 1054 / 694
thematrix : 832 / 109 : Stage = 1054 / 694
thematrix : 896 / 109 : Stage = 1054 / 694
thematrix : 960 / 109 : Stage = 1054 / 694
thematrix : 1024 / 109 : Stage = 1054 / 694
thematrix : 1088 / 109 : Stage = 1054 / 694
thematrix : 0 / 109 : Stage = 1114 / 713
thematrix : 64 / 109 : Stage = 1114 / 713
thematrix : 128 / 109 : Stage = 1114 / 713
thematrix : 192 / 109 : Stage = 1114 / 713
thematrix : 256 / 109 : Stage = 1114 / 713
thematrix : 320 / 109 : Stage = 1114 / 713
thematrix : 384 / 109 : Stage = 1114 / 713
thematrix : 448 / 109 : Stage = 1114 / 713
thematrix : 512 / 109 : Stage = 1114 / 713
thematrix : 576 / 109 : Stage = 1114 / 713
thematrix : 640 / 109 : Stage = 1114 / 713
thematrix : 704 / 109 : Stage = 1114 / 713
thematrix : 768 / 109 : Stage = 1114 / 713
thematrix : 832 / 109 : Stage = 1114 / 713
thematrix : 896 / 109 : Stage = 1114 / 713
thematrix : 960 / 109 : Stage = 1114 / 713
thematrix : 1024 / 109 : Stage = 1114 / 713
thematrix : 1088 / 109 : Stage = 1114 / 713
thematrix : 1152 / 109 : Stage = 1114 / 713
thematrix : 0 / 109 : Stage = 1120 / 714
thematrix : 64 / 109 : Stage = 1120 / 714
thematrix : 128 / 109 : Stage = 1120 / 714
thematrix : 192 / 109 : Stage = 1120 / 714
thematrix : 256 / 109 : Stage = 1120 / 714
thematrix : 320 / 109 : Stage = 1120 / 714
thematrix : 384 / 109 : Stage = 1120 / 714
thematrix : 448 / 109 : Stage = 1120 / 714
thematrix : 512 / 109 : Stage = 1120 / 714
thematrix : 576 / 109 : Stage = 1120 / 714
thematrix : 640 / 109 : Stage = 1120 / 714
thematrix : 704 / 109 : Stage = 1120 / 714
thematrix : 768 / 109 : Stage = 1120 / 714
thematrix : 832 / 109 : Stage = 1120 / 714
thematrix : 896 / 109 : Stage = 1120 / 714
thematrix : 960 / 109 : Stage = 1120 / 714
thematrix : 1024 / 109 : Stage = 1120 / 714
thematrix : 1088 / 109 : Stage = 1120 / 714
thematrix : 1152 / 109 : Stage = 1120 / 714
thematrix : 0 / 109 : Stage = 1123 / 715
thematrix : 64 / 109 : Stage = 1123 / 715
thematrix : 128 / 109 : Stage = 1123 / 715
thematrix : 192 / 109 : Stage = 1123 / 715
thematrix : 256 / 109 : Stage = 1123 / 715
thematrix : 320 / 109 : Stage = 1123 / 715
thematrix : 384 / 109 : Stage = 1123 / 715
thematrix : 448 / 109 : Stage = 1123 / 715
thematrix : 512 / 109 : Stage = 1123 / 715
thematrix : 576 / 109 : Stage = 1123 / 715
thematrix : 640 / 109 : Stage = 1123 / 715
thematrix : 704 / 109 : Stage = 1123 / 715
thematrix : 768 / 109 : Stage = 1123 / 715
thematrix : 832 / 109 : Stage = 1123 / 715
thematrix : 896 / 109 : Stage = 1123 / 715
thematrix : 960 / 109 : Stage = 1123 / 715
thematrix : 1024 / 109 : Stage = 1123 / 715
thematrix : 1088 / 109 : Stage = 1123 / 715
thematrix : 1152 / 109 : Stage = 1123 / 715
thematrix : 0 / 109 : Stage = 1125 / 715
thematrix : 64 / 109 : Stage = 1125 / 715
thematrix : 128 / 109 : Stage = 1125 / 715
thematrix : 192 / 109 : Stage = 1125 / 715
thematrix : 256 / 109 : Stage = 1125 / 715
thematrix : 320 / 109 : Stage = 1125 / 715
thematrix : 384 / 109 : Stage = 1125 / 715
thematrix : 448 / 109 : Stage = 1125 / 715
thematrix : 512 / 109 : Stage = 1125 / 715
thematrix : 576 / 109 : Stage = 1125 / 715
thematrix : 640 / 109 : Stage = 1125 / 715
thematrix : 704 / 109 : Stage = 1125 / 715
thematrix : 768 / 109 : Stage = 1125 / 715
thematrix : 832 / 109 : Stage = 1125 / 715
thematrix : 896 / 109 : Stage = 1125 / 715
thematrix : 960 / 109 : Stage = 1125 / 715
thematrix : 1024 / 109 : Stage = 1125 / 715
thematrix : 1088 / 109 : Stage = 1125 / 715
thematrix : 1152 / 109 : Stage = 1125 / 715
thematrix : 0 / 109 : Stage = 1127 / 716
thematrix : 64 / 109 : Stage = 1127 / 716
thematrix : 128 / 109 : Stage = 1127 / 716
thematrix : 192 / 109 : Stage = 1127 / 716
thematrix : 256 / 109 : Stage = 1127 / 716
thematrix : 320 / 109 : Stage = 1127 / 716
thematrix : 384 / 109 : Stage = 1127 / 716
thematrix : 448 / 109 : Stage = 1127 / 716
thematrix : 512 / 109 : Stage = 1127 / 716
thematrix : 576 / 109 : Stage = 1127 / 716
thematrix : 640 / 109 : Stage = 1127 / 716
thematrix : 704 / 109 : Stage = 1127 / 716
thematrix : 768 / 109 : Stage = 1127 / 716
thematrix : 832 / 109 : Stage = 1127 / 716
thematrix : 896 / 109 : Stage = 1127 / 716
thematrix : 960 / 109 : Stage = 1127 / 716
thematrix : 1024 / 109 : Stage = 1127 / 716
thematrix : 1088 / 109 : Stage = 1127 / 716
thematrix : 1152 / 109 : Stage = 1127 / 716
That output says that it resets back to 0 / 109 whenever you resize the stage, but you are saying it is centered???

CyanBlue
not centered but not on x= 0;
when i strech the window it goes way inside but is repeated on the right side endlessly

:S
Can you post a screenshot or something???  What's happening and what it should be...

CyanBlue
its supposed to start from the begining of the left side of the swf file

I cant use Stage.align = "TL";

Itll mess up a million other things on my project.
I hate loops I cant seen to understand how "i" works :S
x.jpg
So, the first red box should be sitting right below the red Close button???

See if you can attach a sample file for me???

CyanBlue
yes, right under it
See if you can attach a sample file for me???

CyanBlue
:)

sry didnt get u the first time
files.zip
ASKER CERTIFIED SOLUTION
Avatar of CyanBlue
CyanBlue
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial