Programming movie clips

/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?


Nope :slight_smile:
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?

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

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?

actually I dont :stuck_out_tongue:

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.

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:


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){
_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(_x < 0-_width){

function place(){
eval(“line”+i)._x = xarray*;
eval(“line”+i)._y = yarray*;

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:


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!

thanks again suprab!

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


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

i do EVERYTHING by hand =]

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

hi again

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

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++){ …


In frame 1 of the mainstage

and then u have the code for “function place(){” which I dont know where to put :confused: (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 :frowning: *

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.

=[ u guys rok

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 :slight_smile: ).

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

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.

I’ve added my E-Mail!