# Programming movie clips

**URL:** https://forum.kirupa.com/t/programming-movie-clips/3735
**Category:** programming
**Created:** [October 3, 2001, 11:09am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735 "2001-10-03T11:09:47Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 3, 2001, 11:09am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/1 "2001-10-03T11:09:47Z")

</div>

Hi!  
_/me again doing my site and encounting problems_

I have this movie clip where lines move quite randomly across the screen, back and forth (all manually tweened). So then I implement this movie clip into the main stage… and it’s doing it’s thing…

The problem:  
When I click a button I want those lines to position exactly where I want it to… so can u like program the movie from that button click and say for instance “line2.\_x = 200” (or something like that) and then all the other lines in the movie clip?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 3, 2001, 4:03pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/2 "2001-10-03T16:03:35Z")

</div>

yup

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 3, 2001, 6:21pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/3 "2001-10-03T18:21:05Z")

</div>

Nope 🙂  
If you wanna do that, you need to make your lines into movieclips, else you can’t “talk” to them with Ascript.  
Best thing is, make ONE line-clip, and reuse (instantiate) it with different instance names and parameters (width, position…). Keeps file size low…  
Can U figure this out, clear enuff?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 3, 2001, 11:59pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/4 "2001-10-03T23:59:27Z")

</div>

hey man i read that and i even understood half of it… so u better =]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 5, 2001, 11:27am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/5 "2001-10-05T11:27:28Z")

</div>

yawn…ok: ok  
1/draw a line  
2/F8 to make it a symbol (grafic)  
3/it’s in your library now, so you could use it as often as you want by just draging it out. But 1st, duplicate as Clip so you can use it with ActionScript.  
4/Drag any number of this clip on your stage, and NAME each of these (instances) with a unique name, if you’re gonna use loops to move’em, it’s easiest to use numbers as names.  
5/change width, position, color, alpha to what you want to start with  
6/rest is scripting…know 'bout that?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 5, 2001, 12:37pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/6 "2001-10-05T12:37:23Z")

</div>

actually I dont 😛

When u load the page I want the lines to move random across the screen in a loop… until u click a button, then I want the lines to move to a specific x and y position.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 5, 2001, 3:31pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/7 "2001-10-05T15:31:29Z")

</div>

this board is f\*\*ked today. weird formatting issues

in the preview, the line breaks stopped registering near the end, a warning, just in case. and sometimes it’s italic! what the f\*\*k!

ok, just for kicks, this is not quite what you want, but it’s  
close, edit to taste.

draw a line, make it a movie, name it “line0”, that’s a zero.

put this in frame 1 of your main timeline:

for(i=1;i\<10;i++){  
duplicateMovieClip(“line0”,“line”+i,i);  
}

xarray = [“23”,“42”,“463”,“46”,“296”,“100”,“350”,“235”,“191”,“432”];  
yarray = [“188”,“275”,“23”,“56”,“63”,“225”,“89”,“46”,“235”,“45”];

function reset(targ){  
with(targ){  
\_x = 600; // this is how wide the movie is  
\_y = Math.random()\*250+25; // this is how tall the range is  
eval(targ).speed = Math.random()_15+15; // how fast  
\_width = 256_(Math.random()+1); // how long  
}  
}

function move(targ){  
if(done){return;}else{  
with(targ){  
if(\_x \< 0-\_width){  
reset(targ);  
}else{  
\_x-=speed;  
}  
}  
}}

function place(){  
for(i=0;i\<10;i++){  
eval(“line”+i).\_x = xarray\*;  
eval(“line”+i).\_y = yarray\*;  
}  
done=1;  
}

whew!! almost done, this is hard work. ; )

select line0, move it so it’s all the way off the left of the stage, and put this in the actions:

onClipEvent(enterFrame){  
\_root.move(this);  
}

triggering the place() function will make all the lines go to their corresponding values in the x and y arrays.

this is a good example of how arrays can be so handy!

good luck!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 6, 2001, 9:54am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/8 "2001-10-06T09:54:09Z")

</div>

thanks again suprab!

/me getting started right away with it… boii… that’s alot of code 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 6, 2001, 4:04pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/9 "2001-10-06T16:04:16Z")

</div>

YOU GUYS ACTUALY DO THAT BY YOURSELVES???

MAN… i use 3d aplications and i guess this is why i dont use maya’s MEL =]

i do EVERYTHING by hand =]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 7, 2001, 3:33am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/10 "2001-10-07T03:33:55Z")

</div>

Supra… Fantastic answer… That’s a snippet for the library…  
thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 10, 2001, 8:15am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/11 "2001-10-10T08:15:50Z")

</div>

hi again

it’s absolutely great when you get suprabeeners super ultra advanced(for me it is) solutions to work 🙂

since I’m so new to this, where to put the code isn’t that clear to me.

## I put:

## for(i=1;i\<10;i++){ … … … \_x-=speed; } } }}

In frame 1 of the mainstage

and then u have the code for “function place(){” which I dont know where to put 😕 (i’ve tried to put it in frame 1 and in the actions for the line… nothing works…

and then I’ve put “onClipEvent(enterFrame){ \_root.move(this); }” in the actions for the line… then when I run it i get 1/2 errors and nothing is moving…

I’m just a copy/paster, so for me to try and figure out where to put everything is mission:impossible

Thank’s for the help

\*n00bis need precise explanation ☹ \*

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 10, 2001, 5:13pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/12 "2001-10-10T17:13:59Z")

</div>

that’s right, everything goes in frame 1 level 1 except the onClipEvent{  
&nbsp &nbsp &nbsp &nbsp \_root.move(this);  
}

and where ever you put the place() function.

here’s something that might help. the code is such that the reset function needs to be run in order for movement to happen. make sure you line is well off the left of the stage. if you go into your line movie, select the line, and align left to stage so that the crosshairs appear on the left end of the line, then you’ll be looking at it like the code is.

otherwise, a straight cut and paste should make this work. the place() function is quite sudden though, you may want to work out a way around that.

let me know.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 11, 2001, 1:52am UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/13 "2001-10-11T01:52:20Z")

</div>

=[ u guys rok

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 12, 2001, 5:14pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/14 "2001-10-12T17:14:50Z")

</div>

I don’t understand @#%$!  
I thought the idea sounded cool… but I can’t get it to work.

Could you explain to me as though I was a real n00b. (I am 🙂 ).

Maybe even make a .fla and post it. I have learned many other things from just looking at the completed product.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 12, 2001, 6:14pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/15 "2001-10-12T18:14:05Z")

</div>

add an email to your profile (you can do this without actually revealing your email) and i’ll mail you the fla i made while ensuring that this technique would work.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 14, 2001, 5:10pm UTC](https://forum.kirupa.com/t/programming-movie-clips/3735/16 "2001-10-14T17:10:59Z")

</div>

Done!  
I’ve added my E-Mail!
