Comunidad de diseño web y desarrollo en internet online

Animar datos de php en flash

Citar            
MensajeEscrito el 26 Jun 2008 11:10 am
Hola a todos.

Mi problema es el siguiente y espero poder explicarlo:
Recibo datos de una BD, los cuales hacen un boton por cada dato. Hasta aqui bien
Al darle a estos botones sale una foto y el texto de dicha foto.

Lo que quiero es que si me salen 7 botones, al darle al primero los otros 6 de abajo se muevan en el eje _y.

Muchas gracias por adelantado

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 01:34 pm
Pregunta: ¿eres capaz de mover uno solo? Si es así, pon como y arrancamos desde allí

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 26 Jun 2008 01:51 pm
Hola, gracias por responder.

Consigo mover el boton que pulso pero sin easing, osea su propiedad _y.
Pero lo que necesito es que se muevan los demas hacia abajo en vez del que he pulsado

De nuevo muchas gracias

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 01:53 pm
perdona, te pongo el codigo:
datos_bd.onLoad = function(exito) {
if (exito) {
if (this.output == "ok") {
this.total = parseInt(this.total);
for (var n = 1; n<this.total+1; n++) {
var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.caja_txtcuatro.text = this["nombre"+n];
nom.id_ficha = this["id_ficha"+n];

nom.onRelease = function() {
this._parent.obtenerDetalle(this.id_ficha);
this._y=this._y+y
}

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:26 pm
Please, dale formato a tu código que así es difícil de entender

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:28 pm
no se como darle formato, es la primera vez que me meto en un foro a preguntar.
Lo siento

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:40 pm
Donde puse formato, verás que está subrayado y en azul, es un link, si lo presionas se abre una ventana que te lo explica

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:43 pm

Código :

datos_bd.onLoad = function(exito) {
if (exito) {
if (this.output == "ok") {
this.total = parseInt(this.total);
for (var n = 1; n<this.total+1; n++) {
var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.caja_txtcuatro.text = this["nombre"+n];
nom.id_ficha = this["id_ficha"+n];

nom.onRelease = function() {
this._parent.obtenerDetalle(this.id_ficha);
this._y=this._y+y
}

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:45 pm
Si quieres que los demás vayan hacia abajo cuando presiones uno, entonces cuando vayas a presionar otro no pueden ir los demás hacia abajo sino que el presionado tiene que regresar arriba, bueno si es así aquí te dejo una solución, sitúa este código en el primer frame de una pelicula en blanco, la función que anima los botones se llama animateButtons practicamente lo que hace es hacer un ciclo sobre todos los botones, si es el botón presionado moverlo hacia arriba (yIni) y para los demás moverlos hacia abajo (yFin). Le he añadifo un easing, pero si no te hace falta solamente no hagas un onEnterFrame y dale las _y que desees.

Código :

var estilo:TextFormat = new TextFormat();
estilo.font = "Arial";
estilo.size = 11;

var botones:Array = new Array("boton 1", "boton 2", "boton 3", "boton 4", "boton 5");
var ancho:Number = 80;
var alto:Number = 20;

var boton:MovieClip;
var texto:TextField;
var posX:Number = 20;

var yIni:Number = 20;
var yFin:Number = 100;

for (var i:Number = 1; i<=botones.length; i++) {

   boton = this.createEmptyMovieClip("boton_"+i, this.getNextHighestDepth());
   boton.numero = i;

   with (boton) {

      beginFill(0xCCCCCC,100);
      moveTo(0,0);
      lineTo(ancho,0);
      lineTo(ancho,alto);
      lineTo(0,alto);
      lineTo(0,0);
      endFill();

   }
   texto = boton.createTextField("texto", 1, 10, 0, 0, 0);

   with (texto) {

      autoSize = true;
      selectable = false;
      text = botones[i-1];
      setTextFormat(estilo);

   }
   boton._x = posX;
   boton._y = yIni;
   posX += boton._width+20;

   //---Acciones
   boton.onPress = animateButtons;
}

//---Función de animar los botones
function animateButtons():Void {
   
   var numero:Number = this.numero;
   var bot:MovieClip;
   var fin:Number;

   for (var i:Number = 1; i<=botones.length; i++) {

      bot = this._parent["boton_"+i];

      if (numero == i) {

         bot.fin = yIni;

      } else {

         bot.fin = yFin;

      }
      bot.onEnterFrame = function():Void  {

         var difY:Number = (this.fin-this._y)*.25;

         this._y += difY;

         if (this._y == this.backup) {

            this.backup = null;
            delete this.onEnterFrame;

         } else {

            this.backup = this._y;

         }
      };
   }
}


Para darle formato al texto, cópialo de tu script original y pégalo entre los tags de code, los botones azules encima de la ventana de escribir, hay uno que dice code, presiónalo dos veces y copia tu código en el medio

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:49 pm
Disculpa solisarg, en lo que escribía la respuesta, le has respondido como formatear el código, un ejemplo visual siempre es mejor, saludos amigo.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:50 pm
Muchas gracias.
No se si es lo que busco.
Mi intencion era hacer un menu acordeon con php y javascript, donde cada persiana fuera un campo y al pulsar saliese la informacion.
Me resultaba imposible y lo intente en flash, me resulto mas imposible aun y ahora estoy de nuevo rompiendome la cabeza de como puedo hacerlo en javascript con php :)))

Asi que si tienes algun consejo te lo agradeceria aunque ya se que no es el foro.

Gracias. Un saludo

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 02:56 pm
Tiene casi el mismo nivel de dificultad hacerlo en javascript que en AS, yo diría que en AS te da más facilidades, pero busca en google librerías de Ajax, las de google y las de yahoo son muy buenas, ahí deberías encontrar ya una clase para hacer un acordeón solamente con cambiarle parámetros.

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:00 pm
Si, solo me faltaba saber como se mueven los datos externos que entran en php y ahora he conseguido que me haga una persiana por cada dato obtenido de php en javascript pero solo consigo que se mueva una.

Lo que no se es como hacer un index en javascript con php.

Que te puedes esperar de un codigo que tiene el simbolo del dolar?? :)

De todos modos gracias, te lo has currado

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:01 pm
Mira recordé que tenía un ejemplo de entrenamiento de cuando empecé con lo del javascript, quizás te pueda servir, está muy arcaico y está hecho con arreglos, pero quizás puedas modificarlo para que lea de una base de datos y aprovechar algo del código.

http://www.megaupload.com/?d=9R0F5G0F

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:02 pm
Chininet es el nuevo Eliseo, disfruta de sus respuestas/tutoriales
Te lo has currado ;)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:04 pm
perdona pero el link es una pagina de contactos

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:05 pm
Lo mas sencillo en javascript es que cada submenu lo crees dentro del div del menu y vas cambiando el style de display de estos submenús, en este ejemplo se oculta un submenu cuando se presiona otro pero si quieres puedes hacerlo alrevés, así cuando se muestre un submenu, entonces automáticamente todos los demás items se moverían hacia abajo.

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:15 pm
Jaaa, solisarg tienes razón. :wink:
klin isbud cuando entres en el link que te di pones el código que te pide e irás directo al download, espera el contador.

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:27 pm
y cual es el codigo???

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:28 pm
a vale, ok, gracias

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:53 pm
hola, he estado probando el codigo que me pusistes y no me funciona.
Se que debe ser una tonteria pero es lo que me falta para terminar esto.

tengo una base de datos con varias filas y por cada fila me hace un boton en flash.
Lo que quiero es que al pulsar el primer boton los demas bajen hacia abajo, lo del tamaño me daria igual por que tengo scroll de flash que cambia el del navegador.

Tambien me gustaria que cuando bajes y pulses otro boton el primero no se cierre.

Espero haberlo explicado bien.
De todas formas pongo todo el codigo de esta seccion:
[code]

var inicioX:Number = 0;
var inicioY:Number = 20;
var separacionVertical:Number = 30;
var y:Number = 300;
mostrarDetalle = function (exito:Boolean) {
if (exito) {
if (this.output == "ok") {
detalles.htmlText = "";
detalles.htmlText = "<font color='#444444' size='12' weigth='bold'>"+this.nombre+"</font><br>";
detalles.htmlText += "<font color='#444444'>"+this.fecha+"</font><br><br>";
foto.loadMovie("subirDB/fotografiasnoticias/"+this.imagen);
detalles.htmlText += "<font color='#444444'>Descrpcion:<br></font> "+this.descripcion+"<br>";
foto._alpha = 100;

} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "Error al cargar los datos del usuario";
}
};
obtenerDetalle = function (id_ficha:Number) {
var detalle_usuario:LoadVars = new LoadVars();
detalle_usuario.hacer = "datos";
detalle_usuario.id_ficha = id_ficha;
detalle_usuario.onLoad = mostrarDetalle;
detalle_usuario.sendAndLoad("http://localhost/juan/loadcopia.php", detalle_usuario, "POST");
};
var datos_bd:LoadVars = new LoadVars();
datos_bd.hacer = "todos";
datos_bd.onLoad = function(exito) {
if (exito) {
if (this.output == "ok") {
this.total = parseInt(this.total);
for (var n = 1; n<this.total+1; n++) {
var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.caja_txtcuatro.text = this["nombre"+n];
nom.id_ficha = this["id_ficha"+n];

nom.onRelease = function() {
this._parent.obtenerDetalle(this.id_ficha);
//AQUI IRIA LA FUNCION PERO NO SE CUAL ES, TODO LO DEMAS FUNCIONA
}
nom.onRollOver = function() {
this.gotoAndPlay("on");
};
nom.onRollOut = function() {
this.gotoAndPlay("out");
};
}
detalles.htmlText = "";
} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "<b>Error al cargar los datos</b>";
}
};
datos_bd.sendAndLoad("http://localhost/juan/loadcopia.php", datos_bd, "POST");
[code]

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:54 pm
var inicioX:Number = 0;
var inicioY:Number = 20;
var separacionVertical:Number = 30;
var y:Number = 300;
mostrarDetalle = function (exito:Boolean) {
if (exito) {
if (this.output == "ok") {
detalles.htmlText = "";
detalles.htmlText = "<font color='#444444' size='12' weigth='bold'>"+this.nombre+"</font><br>";
detalles.htmlText += "<font color='#444444'>"+this.fecha+"</font><br><br>";
foto.loadMovie("subirDB/fotografiasnoticias/"+this.imagen);
detalles.htmlText += "<font color='#444444'>Descrpcion:<br></font> "+this.descripcion+"<br>";
foto._alpha = 100;

} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "Error al cargar los datos del usuario";
}
};
obtenerDetalle = function (id_ficha:Number) {
var detalle_usuario:LoadVars = new LoadVars();
detalle_usuario.hacer = "datos";
detalle_usuario.id_ficha = id_ficha;
detalle_usuario.onLoad = mostrarDetalle;
detalle_usuario.sendAndLoad("http://localhost/juan/loadcopia.php", detalle_usuario, "POST");
};
var datos_bd:LoadVars = new LoadVars();
datos_bd.hacer = "todos";
datos_bd.onLoad = function(exito) {
if (exito) {
if (this.output == "ok") {
this.total = parseInt(this.total);
for (var n = 1; n<this.total+1; n++) {
var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.caja_txtcuatro.text = this["nombre"+n];
nom.id_ficha = this["id_ficha"+n];

nom.onRelease = function() {
this._parent.obtenerDetalle(this.id_ficha);
//AQUI IRIA LA FUNCION PERO NO SE CUAL ES, TODO LO DEMAS FUNCIONA
}
nom.onRollOver = function() {
this.gotoAndPlay("on");
};
nom.onRollOut = function() {
this.gotoAndPlay("out");
};
}
detalles.htmlText = "";
} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "<b>Error al cargar los datos</b>";
}
};
datos_bd.sendAndLoad("http://localhost/juan/loadcopia.php", datos_bd, "POST");

Código :

Código :

					

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 03:54 pm

Código :

var inicioX:Number = 0;
var inicioY:Number = 20;
var separacionVertical:Number = 30;
var y:Number = 300;
mostrarDetalle = function (exito:Boolean) {
if (exito) {
if (this.output == "ok") {
detalles.htmlText = "";
detalles.htmlText = "<font color='#444444' size='12' weigth='bold'>"+this.nombre+"</font><br>";
detalles.htmlText += "<font color='#444444'>"+this.fecha+"</font><br><br>";
foto.loadMovie("subirDB/fotografiasnoticias/"+this.imagen);
detalles.htmlText += "<font color='#444444'>Descrpcion:<br></font> "+this.descripcion+"<br>";
foto._alpha = 100;

} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "Error al cargar los datos del usuario";
}
};
obtenerDetalle = function (id_ficha:Number) {
var detalle_usuario:LoadVars = new LoadVars();
detalle_usuario.hacer = "datos";
detalle_usuario.id_ficha = id_ficha;
detalle_usuario.onLoad = mostrarDetalle;
detalle_usuario.sendAndLoad("http://localhost/juan/loadcopia.php", detalle_usuario, "POST");
};
var datos_bd:LoadVars = new LoadVars();
datos_bd.hacer = "todos";
datos_bd.onLoad = function(exito) {
if (exito) {
if (this.output == "ok") {
this.total = parseInt(this.total);
for (var n = 1; n<this.total+1; n++) {
var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.caja_txtcuatro.text = this["nombre"+n];
nom.id_ficha = this["id_ficha"+n];

nom.onRelease = function() {
this._parent.obtenerDetalle(this.id_ficha);
//AQUI IRIA LA FUNCION PERO NO SE CUAL ES, TODO LO DEMAS FUNCIONA
}
nom.onRollOver = function() {
this.gotoAndPlay("on");
};
nom.onRollOut = function() {
this.gotoAndPlay("out");
};
}
detalles.htmlText = "";
} else {
detalles.htmlText = "Se produjo el siguiente error: <b>"+this.msg+"</b>";
}
} else {
detalles.htmlText = "<b>Error al cargar los datos</b>";
}
};
datos_bd.sendAndLoad("http://localhost/juan/loadcopia.php", datos_bd, "POST");

Por klin isbud

8 de clabLevel



 

firefox
Citar            
MensajeEscrito el 26 Jun 2008 04:03 pm
No me funciona = házmelo
NPI = te pongo todo el código (con fondo amarillito porque igual no lo tengo ni formateado en el original)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 26 Jun 2008 04:14 pm
A ver si entiendes lo que te puse en el código:

dentro de cada botón que crees introduces una variable número:

Código :

var nom = attachMovie("nombre", "descripcion"+n, n+1, {_x:inicioX, _y:inicioY+(separacionVertical*(n-1))});
nom.numero = n;


es decir que el botón 1 tendrá una variable dentro de valor 1, el botón dos una de valor 2, etc..

Cuando crees la variable total, guardala donde quieras para acceder a ella, ahora cuando presionas el botón:

Código :

for(var z = 1; z<totalGuardado+1; z++){
                  
   if(z != this.numero){
                  
      this._parent["descripcion"+z]._y += 40;
                                          
   }
                  
}


hacemos un ciclo con la cantidad de botones, y hacemos una condición diciendo que los botones que dentro su variable número sea diferente de la variable número del botón presionado se incremente su propiedad de _y en 40. Es decir que todos los botones menos el presionado incrementarán sus _y en 40.

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 04:22 pm
gracias chichinet, probare con esto y a ti jorge, gracias tambien aunque seas "asi"

Por klin isbud

8 de clabLevel



 

firefox

 

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