Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clip duplication 1

Status
Not open for further replies.

prasoon

Programmer
Nov 15, 2002
67
IN
Houston, we've got a situation here...
could u rectify where the coding algoriths gone wrong here..
actually i am making a flash intro based on the matrix trailor. i ve made the falling matrix code near perfection. but the problem is in order to make multiple instances of my clip flow_mat on the main timeline i have to set each and evry instance manually. i wanted it to do through action script. so i made a new movie and tried the following way.
in my clip <flow_mat>(which has the tweening effect of the matrix) i put the actionin the frame 1~ 5:


this._x=this._x+(Math.random()*4)-2;
this._y=this._y+(Math.random()*4)-2;

to randomize the clip appearance.
then in the 6 frame i put the action:

gotoAndPlay(1);

then in the main timeline i put the following action to duplicate the clip instances:

onload
counter=40; //** this the number of duplication i want**//
while (counter>0)
{
duplicateMovieClip(&quot;mat&quot;,&quot;mat&quot;+counter,counter);
counter= --counter; //** to cycle down the counter**//
}
stop();

where <mat> is my instance name for the clip flow_mat. but when i played the movie there was very negligible duplication and that too just arround the instance that i put on the main movie..

any helps please..
help me out to create the matrix effect through action script..

regards
 
for (i=0; i<40; i++) {
_root.flow_mat.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
this[&quot;newclip&quot; + i]._x= (Math.random()*4)-2;
this[&quot;newclip&quot; + i]._y= (Math.random()*4)-2;
}
 
thanks bill..
i will try that out.. and will contact you if i faced any futher problems..
regards..
by the way ... do u mind if i add u in my list of friends in yahoo messenger..??
 
not at all...and the above code was just to get you on the right lines re syntax.
 
oh.. by the way.. bill should i delete the randomization code from the clip<flow_mat?
regards...
 
without having a clearer idea of exactly what you are trying to do its hard to say. try both and see.
 
hi again bill
later the day i examind the code you gave me.. and found that its just the other way round to write my existing code
i tried both ways.. but it was same as before..
no desired duplication..
what exactly i want is to duplicate the instances of the clip <flow_mat> randomly on the main screen so that when the movie plays the instances will appear here and there all over the screen fllowing down the screen just like the matrix effect.
regards
 
to make sure that the duplication was taking place I changed the code to this

for (i=0; i<40; i++) {
_root.flow_mat.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
this[&quot;newclip&quot; + i]._x= (Math.random()*400)-2;
this[&quot;newclip&quot; + i]._y= (Math.random()*400)-2;
}

duplicated fine. 40 random copies on stage.

i placed one instance of the clip on stage called it flow_mat. in the library i right clicked the clip and gave it a linkage name of flow_mat.
 
ok i will gave it a try again
thanks
prasoon
 
it worked bill
but to give a perfect look i did the following

for (i=0; i<400; i++) {
_root.flow_mat.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
this[&quot;newclip&quot; + i]._x= (Math.random()*900)-2;
this[&quot;newclip&quot; + i]._y= (Math.random()*900)-2;
}

it worked thanks.. but there there was another problem.. can i delay the appearence of these random clips on the screen by few seconds???
regards
 
showNewClip = setInterval(show,100);
i = 0;

function show(){
i ++;
if (i <=400) {
_root.flow_mat.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
this[&quot;newclip&quot; + i]._x= (Math.random()*900)-2;
this[&quot;newclip&quot; + i]._y= (Math.random()*900)-2;
}else{
clearInterval(showNewClip);
}
}
 
Houston....
thanks for the expert advice... all systems online now..
ready and steady to go.
thanks a lot
regards
 
bill ran into problem again..
the clip is duplicating now.. but the the same place.. i tried different no. to multiply with Math.random() still its duplicating at the same place.
what should i do??
Help
regards
 
can you post the code you are using. random is deprecated but it still works.
 
sure..
here is what i am doing...
after opening the blank movie i am creating a new symbol as a movie clip named flow_mat. then i am typing some text in that symbol and making them to tween to give them a look and feel of falling matrix. in the same symbol i am using a different layer called action to write the actionscript. this whole clip is 6 frames long. so in the 1~5 frame of the action layer i am typing :

this._x=_x(Math.random()*40)-2;
this._y=_y(Math.random()*40)-2;

then in the frame of the action layer i.e. frame 6:

gotoAndPlay(1);


after creating this symbol i am putting this symbol in to the main movie, in frame 1. and giving the instance name for this clip as &quot;flow&quot;. Again i am creating another seprate layer for the actions here only 1 frame long. in the frame 1 i am using the code:

showNewClip = setInterval(show,100);
i = 0;

function show(){
i ++;
if (i <=40) {
_root.flow.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
this[&quot;newclip&quot; + i]._x= (Math.random()*900)-2;
this[&quot;newclip&quot; + i]._y= (Math.random()*900)-2;
}else{
clearInterval(showNewClip);
}
}


thats it

the problrm here is.. it duplicates the clip but at the same place.i.e in a straight line. even when i changed the multiplication of math.random()*400/40/100/any thing. it showes the duplicate clips at the same place

regards
 
hmm saw the problem....this fixes it

var i = 0;
nextClip = setInterval(clip,500)
function clip(){
i++;
if (i<40){
_root.flow_mat.duplicateMovieClip (&quot;newClip&quot;+i, i+1);
a = eval([&quot;newclip&quot; + i])
a._x = (Math.random()*300)-2;
a._y = (Math.random()*300)-2;
}else{
clearInterval(nextclip);
}
}
stop();
 
wanna give us a link so we can see your finished product?

(matrix fan here...lol)
 
thanks bill you are my saviour....
i was making this flash intro for a class presentation for my Information Technology class. as the script was not working properly so disabled it temporarly and did evey thing manually. well anyway, i will make it public as soon as possible, cause i am a bit bussy in my finals these days.
thanks
regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top