[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

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

0
zahimezher
Asked:
zahimezher
  • 9
  • 9
1 Solution
 
zahimezherAuthor Commented:
Im using an image in the MC so I dont want to strech teh pic that why Im doin this ! :S
0
 
CyanBlueCommented:
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
0
 
zahimezherAuthor Commented:
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

0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
CyanBlueCommented:
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
0
 
zahimezherAuthor Commented:
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

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

CyanBlue
0
 
zahimezherAuthor Commented:
i have no idea what that means :(
Sry but Im a beginer at this ! The script I pasted b4 "Found on google"
0
 
CyanBlueCommented:
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

0
 
zahimezherAuthor Commented:
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
0
 
CyanBlueCommented:
That output says that it resets back to 0 / 109 whenever you resize the stage, but you are saying it is centered???

CyanBlue
0
 
zahimezherAuthor Commented:
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
0
 
CyanBlueCommented:
Can you post a screenshot or something???  What's happening and what it should be...

CyanBlue
0
 
zahimezherAuthor Commented:
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
0
 
CyanBlueCommented:
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
0
 
zahimezherAuthor Commented:
yes, right under it
0
 
CyanBlueCommented:
See if you can attach a sample file for me???

CyanBlue
0
 
zahimezherAuthor Commented:
:)

sry didnt get u the first time
files.zip
0
 
CyanBlueCommented:
I don't see a way to achieve this without using the Stage.align = "TL";

CyanBlue
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now