PDA

View Full Version : no button duplication of MC


sreebar
02-05-2002, 06:42 AM
Hi,

I have created an MC (motion tween of a BALL that moves 5 frames from left to right). I would like a script which allows me to duplicate that MC on the stage such there are 20 copies of the MC placed in a downward direction vertical line, preferably allowing me to dictate how far apart each copy is, or how far they extend down the stage.

There is no button involved. I simply want all these copies playing over and over as soon as the frame is entered.

Also, is it a simple matter to also have (on the stage at the same time) the BALL moving the opposite direction (right to left now) as well, also repeated 20 times vertically?

Can anyone help me to do this? I'm new to Actionscript, and so please make no assumptions about knowledge on my part. Detailed explanations, please.

Thanks,
sreebar

Ricod
02-05-2002, 07:58 AM
function cloneMc (Amount,CloneTarget,VerticalDistance) {
for (i=0;i<Amount;i++){
duplicateMovieClip (CloneTarget,i,i);
_root[i]._x = _root[CloneTarget]._x;
if (i==0) {
_root[i]._y = _root[CloneTarget]._y + VerticalDistance;
} else if (i>=0) {
_root[i]._y = _root[i-1]._y + VerticalDistance;
}
}
}
Call this function and state how many 'clones' u want, what to clone and how many pixels they should be apart vertically.

I also suggest u take a look at the duplicatemovie tutorial : http://www.actionscripts.org/tutorials/beginner/DuplicateMovieClip/index.shtml

Billy T
02-05-2002, 08:05 AM
ya beat me Ricod ;)

oh well have a look at this file screebar - I commented the scripts

cheers

Ricod
02-05-2002, 08:21 AM
heheh ! We're just TOO eager to help here !

BTW, I saw u joined up at the chat team, but not the beta test team yet Billy T ! I think u'd make a fine addition when the time arrives. Have a look c : http://www.actionscripts.org/forums/showthread.php3?s=&threadid=8784

Billy T
02-05-2002, 08:36 AM
oh yeah I'd been meaning to join the appropriate group(s)

thanks

sreebar
02-05-2002, 03:07 PM
Ricod, where exactly do I put this code?

Ricod
02-05-2002, 03:19 PM
I always put functions on the first frame of the main timeline (_root / _level0). Whenever u want to use the function :

_root.cloneMc (Amount,CloneTarget,VerticalDistance);

replace Amount by the nr. of clones u want, CloneTarget by the path to the object u want to clone (as a string, being "_root.path") and VerticalDistance by the nr. of pixels u want them apart.

sreebar
02-05-2002, 03:20 PM
Billy T,
I can't open the php3 file (perhaps because I have a Mac)...IE doesn't know what to do with it. Can you give me a tip on how to open it or send it to me another way (sreebar@hotmail.com)?

Ricod
02-05-2002, 03:47 PM
php files only work if you are running an internet server supporting php. If u have such a server available, upload the php script there.

To open it to view its content, use notepad or a likewise program.

sreebar
02-05-2002, 04:08 PM
Thanks, Ricod and Billy T. I was able to get the .fla through Netscape instead of IE. Thank you both for your help!

sreebar

Billy T
02-05-2002, 10:05 PM
for future reference - just drag the php file on to stuffit expander and it will expand

cheers

sreebar
02-06-2002, 01:36 AM
Originally posted by Billy T
for future reference - just drag the php file on to stuffit expander and it will expand

cheers

Billy T,

The file you posted worked very well. I just modified it to suit my purposes.

I have a further question re this same project. Is there a code which will allow me to continue the dots around a curved shape? Please see the attached .fla file.

Thanks,
sreebar

Billy T
02-06-2002, 03:50 AM
yeah its do-able

say you want to start the curve at the 11th duplicate

use something like

amount = 20;
i = 1;
curve=5;
while (amount>0) {
duplicateMovieClip (_root.ball1, "mc"+i, i);
setProperty ("mc"+i, _y, (i*20)+30);

if (i<=10){
setProperty ("mc"+i, _x, 30);

}else{
newi=i-1;
setProperty ("mc"+i, _x, _root["mc"+newi]._x+curve);
curve=curve+5;
}
i++;
amount = amount-1;
}

have a look at the attached file - needs some work though

cheers

sreebar
02-06-2002, 07:30 PM
Billy T,

Ah, I have so many questions. I tried the curve code but had 3 problems:
1) modifying it so that the distance between the balls on the curve is the same as on the straight segment.
2) changing the angle of each one of the ball movements on the curve in relation to the curve so that the movement is always at right angles to the curve itself (otherwise, the movement of the balls is always from right to left or left to right).
3) how do I work it so that when I put more than one script on the main timeline, it functions properly? I will explain: I originally put the first "dupeball" code (referring to 2 ball movement MCs) on the main timeline. It worked perfectly. I wanted to use the same code for 2 more ball movement MCs on the main timeline (just different location on the stage). The new 2 didn't show up. What did I do wrong?


thanks in advance,
sreebar

Billy T
02-06-2002, 10:26 PM
as far as the code multiple codes go just duplicate it all in the same frame and change the variables

eg

change amount to amount3
change i to d or whatever

as afar as the distance and the rotation goes you just have to play with that code i gave you. try something like



amount = 20;
i = 1;
curve=3;
while (amount>0) {
duplicateMovieClip (_root.ball1, "mc"+i, i);
setProperty ("mc"+i, _y, (i*20)+30);

if (i<=10){
setProperty ("mc"+i, _x, 30);
setProperty ("mc"+i, _y, (i*20)+30);

}else{
newi=i-1;
setProperty ("mc"+i, _y, (i*20)+(35-curve));
setProperty ("mc"+i, _x, _root["mc"+newi]._x+curve);
setProperty ("mc"+i, _rotation, _root["mc"+newi]._rotation-(curve/3));
curve=curve+2;
}
i++;
amount = amount-1;
}

you have the basic concept - fine tuning it is up to you

goodluck

sreebar
02-06-2002, 10:37 PM
Thanks, I'll give it a try and work with it.

sreebar