Comunidad de diseño web y desarrollo en internet online

Efecto Posición en AS

Citar            
MensajeEscrito el 12 Abr 2007 10:42 pm
Bueno esto es el mismo efecto que hice en su día.



Pero ahora estaba haciendolo todo por AS, y lo que pasa es que se me mueve todo el conjunto e inclusive los botones.

Vereis que hay un moviclip que contiene a los tres elementos, lo cree para que se viera.

Código :


stop();

//Boton 1

var sepr:MovieClip = this.createEmptyMovieClip ("trian"+this.getNextHighestDepth(),this.getNextHighestDepth());

with (sepr)
{
   lineStyle (1,0x000000,15);
   beginFill (0xff0000,55);
   moveTo (0,0);
   lineTo (20,20);
   lineTo (20,20);
   lineTo (20,0);
   lineTo (0,0);
   endFill();
   _x = 30;
   _y = 30;
   
   }
// Botones 2

var sepr2:MovieClip = this.createEmptyMovieClip ("trian2"+this.getNextHighestDepth(),this.getNextHighestDepth());

with (sepr2)
{
   lineStyle (1,0x000000,15);
   beginFill (0x0000ff,55);
   moveTo (0,0);
   lineTo (20,20);
   lineTo (20,20);
   lineTo (20,0);
   lineTo (0,0);
   endFill();
   _x = 30;
   _y = 60;
   
   
   
}
// Botones 3
var sepr3:MovieClip = this.createEmptyMovieClip ("trian3"+this.getNextHighestDepth(),this.getNextHighestDepth());

with (sepr3)
{
   lineStyle (1,0x000000,15);
   beginFill (0x00ff00,55);
   moveTo (0,0);
   lineTo (20,20);
   lineTo (20,20);
   lineTo (20,0);
   lineTo (0,0);
   endFill();
   _x = 30;
   _y = 90;
   

}



var cd4:MovieClip = this.createEmptyMovieClip ("cuadr4"+this.getNextHighestDepth(),this.getNextHighestDepth());
with(cd4)
{
   
   beginFill(0xff0000,10);
   moveTo(0,0);
   lineTo(100,0);
   lineTo(100,100);
   lineTo(0,100);
   _x = 60;
   _y = 30;
   endFill();
   
   
   
   }
/*
// importante, area sensible en AS 

cd4.beginFill(0x000000,0);
cd4.moveTo(0,0);
cd4.lineTo(200,0);
cd4.lineTo(200,200);
cd4.lineTo(0,200);
cd4.endFill();
cd4.onPress = function() {
   this.startDrag();
}
cd4.onRelease = function() {
   this.stopDrag();
}

*/


// Cuadrado 1
var cd1:MovieClip = cd4.createEmptyMovieClip ("cuadr1"+cd4.getNextHighestDepth(),cd4.getNextHighestDepth());

with (cd1)
{
   lineStyle (1,0x000000,15);
   beginFill (0x00ff00,55);
   moveTo (0,0);
   lineTo (20,20);
   lineTo (10,20);

   lineTo (0,30);
   endFill();
   _x = 35;
   _y = 50;
   xpos = 200;
   ypos = 199;
   

}
// Cuadrado 2
var cd2:MovieClip = cd4.createEmptyMovieClip ("cuadr2"+cd4.getNextHighestDepth(),cd4.getNextHighestDepth());

with (cd2)
{
   lineStyle (1,0x000000,15);
   beginFill (0xf0ff00,75);
   moveTo (0,0);
   lineTo (0,20);
   lineTo (20,20);
   lineTo (20,0);
   lineTo (0,0);
   endFill();
   _x = 20;
   _y = 10;
   xpos = 100;
   ypos = 42;
   

}

// Cuadrado 3
var cd3:MovieClip = cd4.createEmptyMovieClip ("cuadr3"+cd4.getNextHighestDepth(),cd4.getNextHighestDepth());

with (cd3)
{
   lineStyle (1,0x000000,15);
   beginFill (0xf0fff0,85);
   moveTo (0,0);
   lineTo (0,20);
   lineTo (20,20);
   lineTo (20,0);
   lineTo (0,0);
   endFill();
   _x = 50;
   _y = 10;
   xpos = 200;
   ypos = 42;

}


cd1.onEnterFrame = function()
{
   

  setProperty("", _x, _x + (xpos - _x) * 2.000000E-001);
    setProperty("", _y, _y + (ypos - _y) * 2.000000E-001);
   
   
 

 
}
cd2.onEnterFrame = function()
{

   
  setProperty("", _x, _x + (xpos - _x) * 2.000000E-001);
    setProperty("", _y, _y + (ypos - _y) * 2.000000E-001);
   
   
 

 
}
cd3.onEnterFrame = function()
{
   
   
  setProperty("", _x, _x + (xpos - _x) * 2.000000E-001);
    setProperty("", _y, _y + (ypos - _y) * 2.000000E-001);
   
   
 

 
}

/* Posiciones */








sepr.onRollOver = function()
{
   
 trace ("Animation 1"+"001");
 
   _root.cd4.cd1.xpos = 200;
_root.cd4.cd1.ypos = 199;
    _root.cd4.cd2.xpos = 100;
   _root.cd4.cd2.ypos = 42;
   _root.cd4.cd3.xpos = 200;
   _root.cd4.cd3.ypos = 42;

}

sepr2.onRollOver = function()
{
 trace ("Animation 2"+"002");
   

}

sepr3.onRollOver = function()
{

   trace ("Animation 3"+"003");

}



Os agradezco la molestia por leerlo.

Por Suriv

131 de clabLevel



 

firefox
Citar            
MensajeEscrito el 13 Abr 2007 01:21 am
Para hacer eso lo mejor es que utilices la clase Tween()
Aquí puedes ver un ejemplo de como usarla. Adapta el código para mover las tres figuras a la vez al presionar los botones indicándole la posiciones finales.

Por Zguillez

BOFH

10744 de clabLevel

85 tutoriales
17 articulos
3 ejemplos

Genero:Masculino   Bastard Operators From Hell Héroes Team Cristalab Editores

BCN

firefox
Citar            
MensajeEscrito el 13 Abr 2007 06:47 am
Ok, gracias lo mirare.......

Por Suriv

131 de clabLevel



 

firefox

 

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