[color=black][font=Arial]I was going through a tutorial, which only gives the script and no explanation, and I ran across something I don’t quite understand. I am sure that it is a duh moment for me but here goes and any input would be greatly appreciated.[/font][/color]
[color=black][/color]
[color=black][font=Arial]This snippet of code makes sense to me mostly all except for the highlighted portions. [/font][/color]
MovieClip.prototype.reset = function() {
// specify the width and height of the movie
width = 550;
height = 200;
// -------------------
var dist, norm; // Here we declare the local variable
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+2;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
// here we set them
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
//
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
[color=black][font=Arial]My question is why do you declare it then set it. Doesn’t it automatically declare it when it is set? [/font][/color]
[color=black][font=Arial] [/font][/color]
[color=black][font=Arial]Again I am sure it is a duh moment so thank you for bearing with me! Oh and I am very new at this whole actionscript thing.[/font][/color]