Comunidad de diseño web y desarrollo en internet online

Efecto humo en as3

Citar            
MensajeEscrito el 24 Feb 2010 03:39 pm
Hola, estoy intentando hacer una animacion en actionscript 3 que tenga humo dinamicamente . Como el que esta en la seccion de tutoriales. Ya que quiero ir variando la intensidad del humo.

http://www.cristalab.com/tutoriales/tutorial-efecto-de-humo-en-flash-c198l/

Pero el tutorial esta en actionscript 2 y lo tengo que hacer en actionscript3. Y no se como hacerlo.
Como lo podria hacer? Como deberia hacer el codigo?

Desde ya muchas gracias

Por cartu_32

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 25 Feb 2010 05:51 pm
y busca en google la "traduccion" de cada funcion de actionscript 2 en actionscript 3 asi podes hacer el efecto de humo de ese tutorial y al mismo tiempo aprendes actionscript 3 ahi te paso una pagina:
http://www.google.com

saludos

Por fermmm

Claber

122 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Feb 2010 12:16 am
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

Por cartu_32

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Feb 2010 01:36 am
disminuis y aumentas la velocidad con la variable "upLift"

Por fermmm

Claber

122 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Feb 2010 02:33 am
Pasa lo mismo, no me disminuye la velocidad. Se me sigue entrecortando la animacion. Lo que pasa es que Uplift me controla la altura del humo, no la velocidad.
Estaba viendo que en el tutorial del humo en as2 hay un atributo del movieclip llamado speed que controla la velocidad. Cual seria el equivalente a speed en as3? O alguna otra forma de poder disminuir la velocidad del humo?

Por cartu_32

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Feb 2010 03:07 am

Código ActionScript :

//We declar our variable 
var upLift:uint = 3;//the amount the smoke will rise 
var wind:uint=0; //the wind intensity 
var speed:uint=20
setInterval(onEnterFrameFunction,speed);
function onEnterFrameFunction() { 
      //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);
      updateAfterEvent();
} 
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); 
   } 
}

Por fermmm

Claber

122 de clabLevel



 

firefox
Citar            
MensajeEscrito el 27 Feb 2010 02:30 am
puedes revisar los videotutoriales que tengo en mi blog explica las diferencias y equivalencas entre as2 y as3 son en español y son excelentes..

Por Shadonwk

50 de clabLevel



 

firefox
Citar            
MensajeEscrito el 02 Mar 2010 07:03 pm
Muchas gracias ya pude hacer que funcione! :)

Por cartu_32

5 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.