SitePoint Sponsor 

User Tag List
Results 1 to 6 of 6

Mar 12, 2002, 17:05 #1
 Join Date
 Feb 2002
 Location
 The Far Side
 Posts
 25
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
Referencing duplicate movie clips
Hi I am trying to reference a number of duplicate movie clips with a loop but ALL the clips seem to be updated with the same info  perhaps the code will help explain..
In frame 1 of main movie..
Code:intClip = "5"; intLoop = "0"; intXSpace = "0"; intYSpace = "0"; intWidth = "34"; while (Number(intLoop)<Number(intClip)) { intLoop = Number(intLoop)+1; dup = "bouncer" add intLoop; duplicateMovieClip ("bouncer", dup, 50 + Number(intLoop)); setProperty (dup, _x, getProperty("bouncer", _x) + Number(intXSpace)); setProperty (dup, _y, getProperty("bouncer", _y) + Number(intYSpace)); intXSpace = Number(intXSpace)+52; if (intLoop == intWidth) { intXSpace = "0"; intYSpace = Number(intYSpace)+52; intWidth = Number(intWidth)+34; } }
Code:// set loop variables loop = "0"; clips = "5"; // initiate the loop while (loop < clips) { loop = Number(loop)+1; // get the name of the clip for this loop clipID = "bouncer" add loop // get the x and y of the cursor xMousePos = Math.round(_root.dragger._x); yMousePos = Math.round(_root.dragger._y); // get the x position of the object xThis = Math.round(_root.clipID._x); // get the y position of the object yThis = Math.round(_root.clipID._y); a = yMousePos  yThis b = xMousePos  xThis ab = Number((a*a))+Number((b*b)); x = "1"; i = "0"; iterations = "10"; while (Number(i)<=Number(iterations)) { x = Number(x)((x*xab)/(2*x)); i = Number(i)+1; } dist = 500  Math.round(x); setProperty(_root.clipID, _xscale, dist); setProperty(_root.clipID, _yscale, dist); }
I can't seem to get the clips to act independanty of each other...
Any ideas?Last edited by PoGoMooSE; Mar 12, 2002 at 17:08.

Mar 12, 2002, 23:26 #2
 Join Date
 Aug 2000
 Location
 San Diego, CA
 Posts
 5,460
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
Is this Flash 5?
If so, try something a little more organized, IMHO.
Code:intClip = 5; intLoop = 0; intXSpace = 0; intYSpace = 0; intWidth = 34; depth = 50; for(i=0;i<intClip;i++) { duplicateMovieClip ("bouncer", "bouncer" + i, depth); thisItem = _root["bouncer"+i]; thisItem._x = intXSpace; thisItem._y = intYSpace; intXSpace += 52; if (intLoop == intWidth) { intXSpace = 0; intYSpace += 52; } }
Although since intLoop is only going to 5 it will never be equal to intWidth which is 34.
And for the part inside each duplicated clip. clipID cannot be used in the fashion you wanted.
You need to use some form of expression like I did below.
Also each duplicated clip will have this code in its first frame. Is this what you wanted.
Code:for(i=0;i<5;i++) { clipID = _root["bouncer" + i]; // get the x and y of the cursor xMousePos = Math.round(_root.dragger._x); yMousePos = Math.round(_root.dragger._y); // get the x position of the object xThis = Math.round(clipID._x); // get the y position of the object yThis = Math.round(clipID._y); a = yMousePos  yThis b = xMousePos  xThis ab = Number((a*a))+Number((b*b)); x = "1"; i = "0"; iterations = "10"; while (Number(i)<=Number(iterations)) { x = Number(x)((x*xab)/(2*x)); i = Number(i)+1; } dist = 500  Math.round(x); clipID._xscale = dist; clipID._yscale = dist; }
Please don't PM me with questions.
Use the forums, that is what they are here for.

Mar 13, 2002, 02:15 #3
 Join Date
 Apr 2001
 Location
 Brussels Belgium
 Posts
 352
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
also...
Code:depth = 50; for(i=0;i<intClip;i++) { duplicateMovieClip ("bouncer", "bouncer" + i, depth);

Mar 13, 2002, 10:05 #4
 Join Date
 Aug 2000
 Location
 San Diego, CA
 Posts
 5,460
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
That was my code not the question asker's, I rewrote alot of their's. I forgot to add the depth++; before the closing brace.
Please don't PM me with questions.
Use the forums, that is what they are here for.

Mar 13, 2002, 17:49 #5
 Join Date
 Feb 2002
 Location
 The Far Side
 Posts
 25
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
Thanks
Thanks  I am still fairly new to this so any help is most appreciated...
It is flash 5  I stripped out the unnesseccary bits  originally I had this mc duplicated about 400 times in rows of 34 so hence the check on intLoop to reset the y position etc...
Basically I am trying to create a "nervous matrix" effect if you have come across that.. my idea is to create a movie clip that responds to the mouse position wherever it's placed on the stage  the mouse is nearer so it gets bigger etc and then duplicate that clip so I have lot's of clips but each checking the mouse position in relation to itself and responding independantly...
Hope that explains it...

Mar 13, 2002, 17:53 #6
 Join Date
 Feb 2002
 Location
 The Far Side
 Posts
 25
 Mentioned
 0 Post(s)
 Tagged
 0 Thread(s)
That did it...
Hey thanks that got it doing what I expected  I am still a long way off the nervous matrix  do you know of a tutorial anywhere on that effect? I what to understand how to do it rather than just copy someone...
Thanks again
Bookmarks