Código :
Object.environment = this;
Math.prototype.degrees = function(r) {
return (r*180/Math.PI);
};
maxtents = 3;
this.onEnterFrame = function() {
if ((tents<maxtents)) {
var nombre1="tent1"+String(depth1++);
var nombre="tent"+String(depth++);
var neo=this.attachMovie("tentacle",nombre,depth);
var neo1=this.attachMovie("tentacle1",nombre1,depth1);
neo._x=400;
neo._y=100;
neo1._x=400;
neo1._y=156;
neo.theta=390;
neo1.theta1=170;
tents++;
}
}
stop();]
y cada movieClip tiene esto como codigo
Código :
/#initclip
// constructor
function TentacleClass() {
// total number of nodes
this.numNodes = 27;
// the general size and speed
this.head = 1+random(2);//movimiento en forma de onda
this.girth = 8+random(12);
// locomotion efficiency (0 - 1)
this.speedCoefficient=.09+random(10)/50;
// the viscosity of the water (0 - 1)
this.friction=.90+random(10)/100;
// muscular range
this.muscleRange=200+random(50);
// muscular frequency
this.muscleFreq=.1+random(100)/15;
// create point array to represent nodes
this.generateNodes();
// swim
this.onEnterFrame = this.move;
}
// allow component to inherit MovieClip properties
TentacleClass.prototype = new MovieClip();
// instance methods
TentacleClass.prototype.generateNodes = function() {
// create all body part nodes
this.node = new Array();
for (var n=0;n<this.numNodes;n++) {
var point = {x:0,y:0};
this.node.push(point);
}
}
TentacleClass.prototype.move = function() {
// mouse handle - uncomment to control tentacles with mouse
this.node[0].x = this._xmouse;
this.node[0].y = this._ymouse;
// directional node with orbiting handle
// arbitrary direction
this.tv+=0.5*(Math.random()-Math.random());
this.theta+=this.tv;
this.tv*=this.friction;
this.node[0].x = -1.5;
this.node[0].y = -9.5;
// muscular node
this.count+=this.muscleFreq;
this.thetaMuscle=this.muscleRange*Math.sin(this.count);
this.node[1].x =-this.head*Math.cos(Math.PI / 180 * (this.theta+this.thetaMuscle));
this.node[1].y = -this.head*Math.sin(Math.PI / 180 * (this.theta+this.thetaMuscle));
// apply kinetic forces down through body nodes
for (var i=2; i<this.numNodes; i++){
var dx = this.node[i].x - this.node[i - 2].x;
var dy = this.node[i].y - this.node[i - 2].y;
var d = Math.sqrt (dx * dx + dy * dy);
this.node[i].x = this.node[i - 1].x + (dx * this.girth) / d;
//trace(this.node[i - 1].x + (dx * this.girth) / d)
this.node[i].y = this.node[i - 1].y + (dy * this.girth) / d;
if (i==2) {
this._x=1;
this._y=1;
if (((this._x+this._width)<0) || ((this._x-this._width)>300) || ((this._y+this._height)<0) || ((this._y-this._height)>200)) {
// no longer visible, remove
Object.environment.tents--;
this.removeMovieClip();
}
}
}
// draw nodes using lines
this.clear();
this.moveTo(this.node[2].x,this.node[2].y);
for (var i=2; i<this.numNodes; i++){
this.lineStyle(int(this.numNodes+i)*(this.numNodes-i)/10, 0xD2271D, 100); // with no head
this.lineTo(this.node[i].x,this.node[i].y);
}
};
// Connect the class with the linkage ID for this movie clip
Object.registerClass("tentacle", TentacleClass);
#endinitcliplo mismo tiene el otro movieClip pero en la ultima linea es
Object.registerClass("tentacle1", TentacleClass);[/quote]
