Encontre un ejemplo en as3. Anda bien, y lo pude incorporar a la animacion que estoy haciendo. El problema es que no puedo disminuir la velocidad del humo. Ya que sino la disminuyo se me entrecorta la animacion que hice. Intente con un timer, pero es lo mismo.¿ Como podria hacer para disminuir la velocidad del humo? Como deberia hacerlo?
En el ejemplo se crea un simbolo clip de pelicula con la imagen de una nube de humo. A este simbolo se lo llama smoke.Despues en un fotograma se escribe el siguiente codigo.
Código ActionScript :
//We declar our variable
var upLift:uint = 3;//the amount the smoke will rise
var wind:uint=0; //the wind intensity
addEventListener(Event.ENTER_FRAME, onEnterFrameFunction);//this will execute the onEnterFrameFunction function every frame
function onEnterFrameFunction(e:Event) {
//this will just get the wind and uplift from the textboxes
upLift = Number(upLiftT.text);
wind = Number(windT.text);
//now we declare a new object. This object is from the lybrary and has the class name "glow"
var smokeElement:smoke = new smoke();
//set the position of the object to the cursor position
smokeElement.x=mouseX;
smokeElement.y=mouseY;
//make the smoke smaller at the begining
smokeElement.width=5;
smokeElement.height=5;
///make the smoke a litle transparent
smokeElement.alpha=0.3;
//ad a random rotation
smokeElement.rotation = Math.random()*360;
//add the item to the stage
addChild(smokeElement);
//ads and event to the object that is executed every frame
smokeElement.addEventListener(Event.ENTER_FRAME, fadeSmoke);
}
function fadeSmoke(e:Event) {
//changes the transparency, the width, the height and also makes if move depending on the wind and uplift
e.currentTarget.alpha+=-0.005;
e.currentTarget.width+=4;
e.currentTarget.height+=4;
e.currentTarget.y-=upLift;
e.currentTarget.x+=wind;
//once it has faded completly, we remove the event from the object and also remove the object from the stage
if (e.currentTarget.alpha<=0) {
e.currentTarget.removeEventListener(Event.ENTER_FRAME, fadeSmoke, false);
e.currentTarget.parent.removeChild(e.currentTarget);
}
}Desde ya muchas gracias