hey guys im trying to get this crazy line drawing thing to not go from a curved line to a straight line when its trying to hit its target. i want to keep it curved when it hits the target. Is there anyone who can help? here’s the script:
download the file to see what i am talking about.
var x = 300;
var y = 50;
var boo=this
cliparray=[]
for (var i = 0; i<5; i++) {
var clop = attachMovie(“t”, “t”+i, i+100);
clop._x = 200+x;
clop._y = i*clop._height+y;
clop.mytext.text = "target "+i;
cliparray.push(clop)
}
delete i;
function myfunction(a) {
for (var i = 0; i<a.length; i++) {
var clip = this.createEmptyMovieClip("paper"+i, i);
clip._x = x;
clip._y = y;
var clap = clip.createEmptyMovieClip("mc", 1);
clap.ivar =i
clap.a=a
clap.startx =0
clap.starty =0
clap.vely = Math.random()/7;
clap.velx = Math.random()/7;
clap.cc = 100+random(45);
clap.anglex = 0;
clap.angley = 0;
clap.targetx = a*._x-x;
clap.targety = a*._y-y;
clap.count = random(20);
clap.onEnterFrame = move;
clip.onEnterFrame = draw;
}
}
//amount of lines and target number
myarray1 = [this[“t”+0], this[“t”+0], this[“t”+0], this[“t”+0]];
myarray2 = [ this[“t”+7], this[“t”+8], this[“t”+9]];
myarray3 = [this[“t”+2], this[“t”+3], this[“t”+4], this[“t”+5], this[“t”+6], this[“t”+8], this[“t”+9]];
for(var i=1;i<4;i++){
this[“btn”+i].ivar = i
this[“btn”+i].onPress=mypress
}
function mypress(){
for(var obj in cliparray){
cliparray[obj].gotoAndStop(1)
}
myfunction(boo[“myarray”+this.ivar])
}
function move() {
this._x = Math.sin(this.angleX += this.velx)*this.cc+this.startx;
this._y = Math.sin(this.angleY += this.vely)this.cc+this.starty;
this.count++;
if (this.count>=100) {
this.onEnterFrame = gettarget;
}
}
function gettarget() {
this._x += (this.targetx-this._x)/1.5;
this._y += Math.sin(this.angle)(this.targety-this._y)/1.5;
this.angle += (360-this.angle);
if (Math.abs(this.targetx-this._x)<3) {
this._x = this.targetx;
this._y = this.targety;
delete this.onEnterFrame;
this.a[this.ivar].gotoAndStop(2)
this._parent.onEnterFrame = fade;
}
}
function fade() {
this._alpha -= 5;
if (this._alpha<0) {
this.removeMovieclip();
}
}
function draw() {
//this.clear()
this.lineStyle(0, 0x97CEF7, 100);
this.lineTo(this.mc._x, this.mc._y);
}