I’m trying to make add this little movie clip to my page but I can’t seem to get it to work properly. What I’m trying to do is this. I have a bunch of short lines and i want them to move up and down smoothly and continously. I looked at the random motion tut on the site but it didn’t look like what I was after.
Can some one help?
Thanks
PS. you can view the site at www.jcgsolutions.ca so you can have a look at what I’m talking about. The movie clip is in the upper right corner.
Just remove EVERYTHING that relates to the _x position of the object. Here… I edited the script for what you want to do, Tried, tested, and true it works…
//special thanks to Suprabeener for the code
function getdistance(y, y1) {
var rise;
rise = y1-y;
return (_root.hyp(rise));
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 300;
height = 400;
//-------------------
var dist, norm;
this.y = this._y;
this.speed = Math.random()*4+2;
this.targy = Math.random()*height;
dist = _root.getdistance(this.y, this.targy);
norm = this.speed/dist;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.y, this.targy)>this.speed) {
this.y += this.diffy;
} else {
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>1000) {
this.reset();
this.t = 0;
}
}
this._y = this.y;
};
Just replace the frame actions with the actions above and it should work the way you wanted.
To change the speed just change this line…
this.speed = Math.random()*4+2;