Código :
// register root as environment
//trace('Main')
Object.environment = this;
// simple rad to degree convertor
Math.prototype.degrees = function(r) {
// given r rads, convert to degrees
//trace(r)
return (r*90/Math.PI);
};
// maximum numbe r of simultaneous tentacles
maxtents = 1;
//trace(maxtents)
this.onEnterFrame = function() {
// trace(random(20))
//random 30 quiere decir que aqui va entrar 30 veces
if ((!random(2)) && (tents<maxtents)) {
// create a new tentacle object
//trace(depth)
var nombre="tent"+String(depth++);
//var nombre1="tent1"+String(depth1++);
//trace(nombre)
var neo=this.attachMovie("tentacle",nombre,depth);
//var neo1=this.attachMovie("tentacle1",nombre1,depth1);
//var neo=this.attachMovie("tentacle",nombre,depth);
// position it at screen bottom
neo._x=200;
neo._y=100;
//neo1._x=236;
//neo1._y=120;
// point up initially
//neo.theta=170;
//neo._x=random(600);
//neo._y=156;
// point up initially
//neo1.theta1=390;
neo.theta=80;
// keep track of number of tentacles
tents++;
}
}
stop();
mientras q el movie clip q utilizo en en atacsh es el siguiente
#initclip
// constructor
function TentacleClass() {
// total number of nodes
this.numNodes = 27;
// the general size and speed
this.head = 1;//movimiento en forma de onda
this.girth = 20;
// 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=20;
// 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;
//trace(this._xmouse)
// directional node with orbiting handle
// arbitrary direction
//trace(Math.random()-Math.random())
this.tv+=0.5;
this.theta+=this.tv;
this.tv*=this.friction;
this.node[0].x = -1.5;
this.node[0].y = -1.5;
// muscular node
this.count+=this.muscleFreq;
this.thetaMuscle=1;
this.node[1].x =-this.head*Math.cos(Math.PI / 90 * (this.theta+this.thetaMuscle));
this.node[1].y = -this.head*Math.sin(Math.PI / 90 * (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;
// check if muscle node is outside of viewable window
if (i==2) {
//trace(dx*this.speedCoefficient)
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((this.numNodes/(i-1))*1.5, 0xFFFFFF, 100); // with head
// this.lineStyle((this.numNodes-i), 0xFFFFFF, 100); // with no head
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);
#endinitclip
//trace('Hola')quisiera saber si puedo agregar otro objeto de la clase TentacleClass, intente hacerlo pero no me lo muestro alguien m puede decir pork q no lo muestra?
