Comunidad de diseño web y desarrollo en internet online

¿Como usar efecto de agua con botones y MC encima?

Citar            
MensajeEscrito el 19 Ene 2009 05:34 pm
Que tal! aqui dandoles lata de nuevo y comenzando a estudiar el AS3 que la verdad si queda muchisimo mejor que en AS2

Mi duda es que encontre un tutorial de como hacer un efecto de agua en una imagen tipo como el de AS2 pero para AS3 y se ve muy bien, solo que al momento de quererle poner botones o MC encima estos quedan por debajo del fondo y no encuentro la programacion adecuada para poder hacer esto, espero me puedan ayudar, aqui les dejo el codigo y el link de donde vi el tutorial. Saludos!

Link :

escribió:

http://crea-flash.com/index.php?option=com_content&task=view&id=30&Itemid=33


Codigo :

Código :


function FxAgua(Imagen:BitmapData,Mc:Object ,INT:Number,mouseEvent,Atc:Boolean):void {
   var Ancho:Number= Imagen.width;
   var Alto:Number =Imagen.height;
   var FondoA= new BitmapData(Ancho,Alto);
   var FondoB = new BitmapData(Ancho,Alto, false,0);
   var PunOrig = new BitmapData(Ancho,Alto, false,128);
   var Contenedor = new BitmapData(Ancho,Alto, false,128);
   var Ola = new ConvolutionFilter(3,3,[1,1,1,1,1,1,1,1,1],9,0);
   var Agua = new ColorTransform(0,0,0.996,1,0,0,2,0);
   var Onda = new DisplacementMapFilter(FondoA,new Point(),4,4,INT,INT,"ignore");
   var Bmp:Bitmap = new Bitmap(FondoB);
   Mc.addChild(Bmp);
   if (Atc) {
      Mc.addEventListener( mouseEvent, CreaMouseF );
      Mc.addEventListener( MouseEvent.MOUSE_UP, CreaMouseU );
   } else {
      Mc.addEventListener( mouseEvent, CreaOnda );
   }
   function CreaMouseF( event:MouseEvent ):void {
      Mc.addEventListener( MouseEvent.MOUSE_MOVE, CreaOnda );
   }
   function CreaMouseU( event:MouseEvent ):void {
      Mc.removeEventListener( MouseEvent.MOUSE_MOVE, CreaOnda );
   }
   function CreaOnda( event:MouseEvent ):void {
      var XM = Mc.mouseX;
      var YM = Mc.mouseY;
      PunOrig.setPixel(XM+1,YM,0);
      PunOrig.setPixel(XM-1,YM,0);
      PunOrig.setPixel(XM,YM+1,0);
      PunOrig.setPixel(XM,YM-1,0);
   }
   Mc.addEventListener(Event.ENTER_FRAME, action);
   function action(event:Event) {
      FondoA.applyFilter(PunOrig,new Rectangle(0, 0, Ancho,Alto),new Point(),Ola);
      FondoA.draw(FondoA,new Matrix(),null,"add");
      FondoA.draw(Contenedor,new Matrix(),null,  "subtract");
      FondoA.draw(FondoA, new Matrix(),Agua);
      FondoB.applyFilter(Imagen,new Rectangle(0,0,Ancho,Alto), new Point(),Onda);
      Contenedor = PunOrig;
      PunOrig = FondoA.clone();
   }
}
// -->Tip 1 = funcion que activa FxAgua desde un archivo de imagen vinculado <--
var NuevoFondo:BitmapData=new fondo1(0,0);
FxAgua(NuevoFondo,stage ,200,MouseEvent.MOUSE_MOVE,false);


addChild(btnImage1); 
btnImage1.buttonMode = true;
btnImage1.mouseChildren = false;

function btnOver(evt:Event):void {
   //trace(evt.target.name);
   evt.target.gotoAndPlay(2);
}

function btnOut(evt:Event):void {
   //trace(evt.target.name);
   evt.target.gotoAndPlay(11);
}


btnImage1.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btnImage1.addEventListener(MouseEvent.ROLL_OUT, btnOut);

Por alexstorm

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 19 Ene 2009 07:05 pm
Asi sin ver codigo ni nada se me ocurre que le des un swap al movieclip o al boton con el fondo algo como

Código ActionScript :

swapChildren(fondo,clip); // y cambian de posicion

Por Angel Roberto

Claber

248 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Ene 2009 07:27 am
También vale con un setChildIndex
Como sabemos, la máxima "depth" (supongo que ahora deberíamos decir "la posición más alta de la display List") es numChildren-1
si escribimos

Código ActionScript :

stage.setChildIndex(mimc,(stage.numChildren-1)),

hará que "mimc" esté en lo más alto de "stage"

Por Eliseo2

710 de clabLevel



 

firefox

 

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