Foros del Web » Creando para Internet » Flash y Actionscript »

slide AS3

Estas en el tema de slide AS3 en el foro de Flash y Actionscript en Foros del Web. Hola Tengo la siguiente duda: Tengo que hacer una galería de imágenes, con unas diez fotos o así. Para ello, tengo 10 botones y dos ...
  #1 (permalink)  
Antiguo 01/11/2011, 08:05
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
slide AS3

Hola

Tengo la siguiente duda:

Tengo que hacer una galería de imágenes, con unas diez fotos o así. Para ello, tengo 10 botones y dos de siguiente y atrás. A la vez quiero hacer un slide, que se mueva en el eje X que me indique en la foto en la que estoy, solo me fata esto, todo lo demás lo tengo. Alguien me puede ayudar??

Muchas Gracias, Un Saludo.
  #2 (permalink)  
Antiguo 01/11/2011, 10:04
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Sólo?, ese es todo un proyecto, facil pero un proyecto, te sugiero busques un tutorial del uso de la clase tween, con eso lo haces.
__________________
Mi sitio: http://www.fluocode.com
  #3 (permalink)  
Antiguo 01/11/2011, 10:21
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

ya tengo exo para que el mc se mueva por debajo de los botones y asi saber en la imagen que estoy...pero como hago que reaccione para los botones de siguiente y atras??

*Pego el codigo del slider:

boton1.addEventListener(MouseEvent.CLICK, sidebar);
boton2.addEventListener(MouseEvent.CLICK, sidebar);
boton3.addEventListener(MouseEvent.CLICK, sidebar);
boton4.addEventListener(MouseEvent.CLICK, sidebar);
boton5.addEventListener(MouseEvent.CLICK, sidebar);
boton6.addEventListener(MouseEvent.CLICK, sidebar);
boton7.addEventListener(MouseEvent.CLICK, sidebar);
boton8.addEventListener(MouseEvent.CLICK, sidebar);
boton9.addEventListener(MouseEvent.CLICK, sidebar);
boton10.addEventListener(MouseEvent.CLICK, sidebar);
function sidebar(e:MouseEvent):void
{
new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.current Target.x,1,true);
}
  #4 (permalink)  
Antiguo 01/11/2011, 10:46
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Código actionscript:
Ver original
  1. //Puedes crear un arreglo con los valores de x de cada botón y un indice que indique en cuel boton estas
  2. var arreglo:Array = new Array(boton1.x,botn2.x);//todos los botones que sean .x
  3. var indice:int = 0;//o la el valor de la primera foto
  4. var numeroDeFotos = 10;//para que el boton de siguiente "sepa" cuando parar
  5.  
  6. //y dos funciones una para atras y una para adelante
  7.  
  8.  
  9. function sidebar(e:MouseEvent):void
  10. {
  11.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  12.     //Con esto avisas en que foto estas actualmente
  13.     switch (e.target.name)
  14.     {//e.target.name es el nombre del boton (teoricamente)
  15.         case boton1 :
  16.             indice = 1;
  17.             break;
  18.         case boton2 :
  19.             indice = 2;
  20.             break;
  21.     }
  22. }
  23.  
  24. function sidebarNext(e:MouseEvent):void
  25. {
  26.     if (indice<numeroDeFotos)
  27.     {
  28.         indice++;
  29.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  30.     }
  31. }
  32. function sidebarBack(e:MouseEvent):void
  33. {
  34.     if (indice>2)
  35.     {
  36.         indice--;
  37.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  38.     }
  39. }
__________________
Mi sitio: http://www.fluocode.com
  #5 (permalink)  
Antiguo 01/11/2011, 11:11
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Muchas gracias¡¡¡

ya casi lo tengo...lo q pasa es q dandole a los botones de siguiente y atras me salta de la imagen 1 a la 3 y de la 10 a la 3...pongo el código:

Código ASP:
Ver original
  1. //Puedes crear un arreglo con los valores de x de cada botón y un indice que indique en cuel boton estas
  2. var arreglo:Array = new Array(boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);//todos los botones que sean .x
  3. var indice:int = 1;//o la el valor de la primera foto
  4. var numeroDeFotos = 10;//para que el boton de siguiente "sepa" cuando parar
  5.  
  6. //y dos funciones una para atras y una para adelante
  7.  
  8.  
  9. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  10. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  11. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  12. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  13. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  14. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  15. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  16. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  17. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  18. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  19. function sidebar(e:MouseEvent):void
  20. {
  21.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  22.     //Con esto avisas en que foto estas actualmente
  23.     switch (e.target.name)
  24.     {//e.target.name es el nombre del boton (teoricamente)
  25.         case boton1 :
  26.             indice = 1;
  27.             break;
  28.         case boton2 :
  29.             indice = 2;
  30.             break;
  31.         case boton3  :
  32.             indice = 3;
  33.             break;
  34.         case boton4 :
  35.             indice = 4;
  36.             break;
  37.         case boton5 :
  38.             indice = 5;
  39.             break;
  40.         case boton6 :
  41.             indice = 6;
  42.             break;
  43.         case boton7 :
  44.             indice = 7;
  45.             break;
  46.         case boton8 :
  47.             indice = 8;
  48.             break;
  49.         case boton9 :
  50.             indice = 9;
  51.             break;
  52.         case boton10 :
  53.             indice = 10;
  54.             break;
  55.     }
  56. }  
  57. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  58. function sidebarNext(e:MouseEvent):void
  59. {
  60.     if (indice < 10)
  61.     {
  62.         indice++;
  63.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  64.     }
  65. }
  66. anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  67. function sidebarBack(e:MouseEvent):void
  68. {
  69.     if (indice > 2)
  70.     {
  71.         indice--;
  72.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  73.     }
  74. }
  #6 (permalink)  
Antiguo 01/11/2011, 11:19
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Lo que pasa es que para acceder al valor de los arreglos se tiene que comenzar desde el 0,

si estas en la primera foto el indice es 1 y le das siguiente el indice es 2 entonces busca el tercer valor del arreglo (0,1,2), la opcion seria recorrer todos los valores... o agregar un valor mas al arreglo al principio, para que ocupe el primer espacio, solo cambia la declaracion del arreglo por la siguiente.

Código actionscript:
Ver original
  1. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,boton6.x,boton7.x,boton8.x,boton9.x,boton10.x)
__________________
Mi sitio: http://www.fluocode.com
  #7 (permalink)  
Antiguo 01/11/2011, 11:27
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Muchas gracias¡¡¡....si eso eraaa¡¡¡ahora va de 1 en 1. Solo que al volver atrás se me qda parado en el dos..
Código ASP:
Ver original
  1. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);
  2. var indice:int = 1;
  3. var numeroDeFotos = 10;
  4. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  5. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  6. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  7. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  8. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  9. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  10. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  11. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  12. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  13. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  14. function sidebar(e:MouseEvent):void{
  15.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  16.     switch (e.target.name){
  17.         case boton1 :
  18.             indice = 1;
  19.             break;
  20.         case boton2 :
  21.             indice = 2;
  22.             break;
  23.         case boton3  :
  24.             indice = 3;
  25.             break;
  26.         case boton4 :
  27.             indice = 4;
  28.             break;
  29.         case boton5 :
  30.             indice = 5;
  31.             break;
  32.         case boton6 :
  33.             indice = 6;
  34.             break;
  35.         case boton7 :
  36.             indice = 7;
  37.             break;
  38.         case boton8 :
  39.             indice = 8;
  40.             break;
  41.         case boton9 :
  42.             indice = 9;
  43.             break;
  44.         case boton10 :
  45.             indice = 10;
  46.             break;
  47.     }
  48. }  
  49. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  50. function sidebarNext(e:MouseEvent):void
  51. {
  52.     if (indice < 10)
  53.     {
  54.         indice++;
  55.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  56.     }
  57. }
  58. anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  59. function sidebarBack(e:MouseEvent):void
  60. {
  61.     if (indice > 2)
  62.     {
  63.         indice--;
  64.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  65.     }
  66. }
  #8 (permalink)  
Antiguo 01/11/2011, 11:31
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Linea 61 de tu codigo

Código actionscript:
Ver original
  1. if (indice > 2)

CAmbialo por

Código actionscript:
Ver original
  1. if (indice > 1)
__________________
Mi sitio: http://www.fluocode.com
  #9 (permalink)  
Antiguo 01/11/2011, 11:32
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

si eso lo he exo y tampoco, no va
  #10 (permalink)  
Antiguo 01/11/2011, 11:53
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Lo he probado y nose porque pero cuando llega a la 10 se va directamente a la 3
Código ASP:
Ver original
  1. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,
  2.                               boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);
  3. var indice:int = 1;
  4. var numeroDeFotos = 10;
  5. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  6. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  7. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  8. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  9. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  10. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  11. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  12. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  13. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  14. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  15. function sidebar(e:MouseEvent):void{
  16.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  17.     switch (e.target.name){
  18.         case boton1 :
  19.             indice = 1;
  20.             break;
  21.         case boton2 :
  22.             indice = 2;
  23.             break;
  24.         case boton3  :
  25.             indice = 3;
  26.             break;
  27.         case boton4 :
  28.             indice = 4;
  29.             break;
  30.         case boton5 :
  31.             indice = 5;
  32.             break;
  33.         case boton6 :
  34.             indice = 6;
  35.             break;
  36.         case boton7 :
  37.             indice = 7;
  38.             break;
  39.         case boton8 :
  40.             indice = 8;
  41.             break;
  42.         case boton9 :
  43.             indice = 9;
  44.             break;
  45.         case boton10 :
  46.             indice = 10;
  47.             break;
  48.     }
  49. }  
  50. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  51. function sidebarNext(e:MouseEvent):void
  52. {
  53.     if (indice < 10)
  54.     {
  55.         indice++;
  56.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  57.     }
  58. }
  59. anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  60. function sidebarBack(e:MouseEvent):void
  61. {
  62.     if (indice > 1)
  63.     {
  64.         indice--;
  65.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  66.     }
  67. }
  #11 (permalink)  
Antiguo 01/11/2011, 12:12
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Lo veo muy raro

Agragale unos trace para ver que valores tiene indice:

y compilas ctrl + enter

Código actionscript:
Ver original
  1. function sidebarNext(e:MouseEvent):void
  2. {
  3.     if (indice < 10)
  4.     {
  5.         trace("valor de indice Inicio: "+indice)
  6.         indice++;
  7.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  8.         trace("valor de indice Final: "+indice)
  9.     }
  10. }
  11. anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  12. function sidebarBack(e:MouseEvent):void
  13. {
  14.     if (indice > 1)
  15.     {
  16.         trace("valor de indice Inicio: "+indice)
  17.         indice--;
  18.         new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  19.         trace("valor de indice Final: "+indice)
  20.     }
  21. }
__________________
Mi sitio: http://www.fluocode.com
  #12 (permalink)  
Antiguo 01/11/2011, 12:25
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Valores de salida de 1 a 10

Código Action Scropt 3.0:
Ver original
  1. valor de indice Inicio: 1
  2. valor de indice Final: 2
  3. valor de indice Inicio: 2
  4. valor de indice Final: 3
  5. valor de indice Inicio: 3
  6. valor de indice Final: 4
  7. valor de indice Inicio: 4
  8. valor de indice Final: 5
  9. valor de indice Inicio: 5
  10. valor de indice Final: 6
  11. valor de indice Inicio: 6
  12. valor de indice Final: 7
  13. valor de indice Inicio: 7
  14. valor de indice Final: 8
  15. valor de indice Inicio: 8
  16. valor de indice Final: 9
  17. valor de indice Inicio: 9
  18. valor de indice Final: 10

Valores de Salida de 10 a 1 (se qda en 2)
Código Action Scrip:
Ver original
  1. valor de indice Inicio: 10
  2. valor de indice Final: 9
  3. valor de indice Inicio: 9
  4. valor de indice Final: 8
  5. valor de indice Inicio: 8
  6. valor de indice Final: 7
  7. valor de indice Inicio: 7
  8. valor de indice Final: 6
  9. valor de indice Inicio: 6
  10. valor de indice Final: 5
  11. valor de indice Inicio: 5
  12. valor de indice Final: 4
  13. valor de indice Inicio: 4
  14. valor de indice Final: 3
  15. valor de indice Inicio: 3
  16. valor de indice Final: 2

Que tengo q modificar??
  #13 (permalink)  
Antiguo 01/11/2011, 12:28
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Hace unas cosas muy raras...si le doy directamente a los botones y luego al de siguiente y atras se mueve de una forma un tanto aleatoria en vez de seguida...es como si pulsando al boton 3 y luego le doy al de siguiente no reacciona el slider pero si la imagen...
  #14 (permalink)  
Antiguo 01/11/2011, 12:31
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Abri el Flash, para probar el codigo, creo que no es del todo bueno hacerlo de memoria

El problema es que en el switch busca que e.target.name sea igual al nombre del boton que fue presionado y el nombre es una cadena por lo tanto debe ir entre comillas, si no hace referencia al objeto.
Código actionscript:
Ver original
  1. import fl.transitions.Tween;
  2. import fl.transitions.easing.*;
  3.  
  4. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,
  5.                               boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);
  6. var indice:int = 1;
  7. var numeroDeFotos = 10;
  8. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  9. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  10. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  11. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  12. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  13. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  14. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  15. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  16. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  17. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  18.  
  19. function sidebar(e:MouseEvent):void{
  20.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  21.     switch (e.target.name){
  22.         case "boton1" :
  23.             indice = 1;
  24.             break;
  25.         case "boton2" :
  26.             indice = 2;
  27.             break;
  28.         case "boton3"  :
  29.             indice = 3;
  30.             break;
  31.         case "boton4" :
  32.             indice = 4;
  33.             break;
  34.         case "boton5" :
  35.             indice = 5;
  36.             break;
  37.         case "boton6" :
  38.             indice = 6;
  39.             break;
  40.         case "boton7" :
  41.             indice = 7;
  42.             break;
  43.         case "boton8" :
  44.             indice = 8;
  45.             break;
  46.         case "boton9" :
  47.             indice = 9;
  48.             break;
  49.         case "boton10" :
  50.             indice = 10;
  51.             break;
  52.     }
  53.     trace(e.target.name)
  54.     trace("indice: "+indice)
  55. }  
  56. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  57.     function sidebarNext(e:MouseEvent):void
  58.     {
  59.         if (indice < 10)
  60.         {
  61.             trace("valor de indice Inicio: "+indice)
  62.             indice++;
  63.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  64.             trace("valor de indice Final: "+indice)
  65.         }
  66.     }
  67.     anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  68.     function sidebarBack(e:MouseEvent):void
  69.     {
  70.         if (indice > 1)
  71.         {
  72.             trace("valor de indice Inicio: "+indice)
  73.             indice--;
  74.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  75.             trace("valor de indice Final: "+indice)
  76.         }
  77.     }
__________________
Mi sitio: http://www.fluocode.com
  #15 (permalink)  
Antiguo 01/11/2011, 12:38
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

ahora me reconoce los botones y la situacion en la que está...pero no lo de siguiente y atras no va...se me sigue parando en el 2
  #16 (permalink)  
Antiguo 01/11/2011, 12:39
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

Valores de Salida de 1 a 10 y de 10 a 1:

Código actionscript:
Ver original
  1. valor de indice Inicio: 1
  2. valor de indice Final: 2
  3. valor de indice Inicio: 2
  4. valor de indice Final: 3
  5. valor de indice Inicio: 3
  6. valor de indice Final: 4
  7. valor de indice Inicio: 4
  8. valor de indice Final: 5
  9. valor de indice Inicio: 5
  10. valor de indice Final: 6
  11. valor de indice Inicio: 6
  12. valor de indice Final: 7
  13. valor de indice Inicio: 7
  14. valor de indice Final: 8
  15. valor de indice Inicio: 8
  16. valor de indice Final: 9
  17. valor de indice Inicio: 9
  18. valor de indice Final: 10
  19. valor de indice Inicio: 10
  20. valor de indice Final: 9
  21. valor de indice Inicio: 9
  22. valor de indice Final: 8
  23. valor de indice Inicio: 8
  24. valor de indice Final: 7
  25. valor de indice Inicio: 7
  26. valor de indice Final: 6
  27. valor de indice Inicio: 6
  28. valor de indice Final: 5
  29. valor de indice Inicio: 5
  30. valor de indice Final: 4
  31. valor de indice Inicio: 4
  32. valor de indice Final: 3
  33. valor de indice Inicio: 3
  34. valor de indice Final: 2
  #17 (permalink)  
Antiguo 01/11/2011, 12:42
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

A mi me funciona perfectamente, ya viste si esta bein escrito el nombre de instacncia de de todos los botones, en especial el del boton2
__________________
Mi sitio: http://www.fluocode.com
  #18 (permalink)  
Antiguo 01/11/2011, 12:50
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

comprobado....los botones estan bien escritos y todo funciona bien excepto eso...que iendo hacia atrás se me qda parado el slide en e boton 2 aunque la imagen si se mueve a la primera
  #19 (permalink)  
Antiguo 01/11/2011, 13:08
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

A mi me funciona muy bien, no se detiene

de hecho esto es lo que da el output:

Código actionscript:
Ver original
  1. valor de indice Inicio: 10
  2. valor de indice Final: 9
  3. valor de indice Inicio: 9
  4. valor de indice Final: 8
  5. valor de indice Inicio: 8
  6. valor de indice Final: 7
  7. valor de indice Inicio: 7
  8. valor de indice Final: 6
  9. valor de indice Inicio: 6
  10. valor de indice Final: 5
  11. valor de indice Inicio: 5
  12. valor de indice Final: 4
  13. valor de indice Inicio: 4
  14. valor de indice Final: 3
  15. valor de indice Inicio: 3
  16. valor de indice Final: 2
  17. valor de indice Inicio: 2
  18. valor de indice Final: 1


Parece que es la condicion

Código actionscript:
Ver original
  1. if (indice > 1)

prueba quitando la la condicion o poniendo >=

o igualando a 0
__________________
Mi sitio: http://www.fluocode.com
  #20 (permalink)  
Antiguo 01/11/2011, 14:06
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

todo eso ta probado y nada...
  #21 (permalink)  
Antiguo 01/11/2011, 14:12
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Aqui el codigo funciona perfectamente quizas hay una sentencia que metiste extra que "corta" el código, porque aqui la barra va y viene perfectamente, si quieres pega todo tu codigo para ver que esta mal, no se si las imagenes de las que hablas esten afectando el funcionamiento.
__________________
Mi sitio: http://www.fluocode.com
  #22 (permalink)  
Antiguo 01/11/2011, 14:15
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

ok...aquí va:

Código action script:
Ver original
  1. import fl.transitions.Tween;
  2. import fl.transitions.easing.*;
  3.  
  4.  
  5. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);
  6. var indice:int = 1;
  7. var numeroDeFotos = 10;
  8.  
  9.  
  10.  
  11. stop();
  12.  
  13.  
  14.  
  15. anterior.visible = false;
  16. siguiente.visible = false;
  17.  
  18. siguiente.addEventListener(Event.ENTER_FRAME, mostrar_botones);
  19. function mostrar_botones (e:Event){
  20.     if(mouseX > 69){
  21.         if(mouseX < 570){
  22.             if(mouseY > 62){
  23.                 if(mouseY < 417){
  24.                     anterior.visible = true;
  25.                     siguiente.visible = true;
  26.                 }else{
  27.                     anterior.visible = false;
  28.                     siguiente.visible = false;
  29.                 }
  30.             }else{
  31.             anterior.visible = false;
  32.             siguiente.visible = false;
  33.              }
  34.         }else{
  35.         anterior.visible = false;
  36.         siguiente.visible = false;
  37.         }
  38.     }else{
  39.     anterior.visible = false;
  40.     siguiente.visible = false;
  41.     }
  42. }
  43.  
  44.  
  45. siguiente.addEventListener(MouseEvent.CLICK, avanzar);
  46. function avanzar (e:MouseEvent){
  47.     nextFrame ();
  48.     mascara.play();
  49. }
  50.  
  51. anterior.addEventListener(MouseEvent.CLICK, atras);
  52. function atras (e:MouseEvent){
  53.     prevFrame ();
  54.     mascara.play();
  55. }
  56.  
  57.  
  58. boton1.addEventListener(MouseEvent.CLICK, imagen1 );
  59. function imagen1 (e:MouseEvent){
  60.     gotoAndStop(1);
  61.     mascara.play();
  62. }
  63.  
  64. boton2.addEventListener(MouseEvent.CLICK, imagen2 );
  65. function imagen2 (e:MouseEvent){
  66.     gotoAndStop (2);
  67.     mascara.play();
  68. }
  69.  
  70. boton3.addEventListener(MouseEvent.CLICK, imagen3 );
  71. function imagen3 (e:MouseEvent){
  72.     gotoAndStop (3);
  73.     mascara.play();
  74. }
  75.  
  76. boton4.addEventListener(MouseEvent.CLICK, imagen4 );
  77. function imagen4 (e:MouseEvent){
  78.     gotoAndStop (4);
  79.         mascara.play();
  80.         mascara.play();
  81. }
  82.  
  83. boton5.addEventListener(MouseEvent.CLICK, imagen5 );
  84. function imagen5 (e:MouseEvent){
  85.     gotoAndStop (5);
  86.     mascara.play();
  87. }
  88.  
  89. boton6.addEventListener(MouseEvent.CLICK, imagen6 );
  90. function imagen6 (e:MouseEvent){
  91.     gotoAndStop (6);
  92.     mascara.play();
  93.  
  94. }
  95.  
  96. boton7.addEventListener(MouseEvent.CLICK, imagen7 );
  97. function imagen7 (e:MouseEvent){
  98.     gotoAndStop (7);
  99.     mascara.play();
  100.  
  101. }
  102.  
  103. boton8.addEventListener(MouseEvent.CLICK, imagen8 );
  104. function imagen8 (e:MouseEvent){
  105.     gotoAndStop (8);
  106.     mascara.play();
  107. }
  108.  
  109. boton9.addEventListener(MouseEvent.CLICK,imagen9);
  110. function imagen9 (e:MouseEvent){
  111.     gotoAndStop (9);
  112.     mascara.play();
  113. }
  114.  
  115. boton10.addEventListener(MouseEvent.CLICK, imagen10 );
  116. function imagen10 (e:MouseEvent){
  117.     gotoAndStop (10);
  118.     mascara.play();
  119. }
  120.  
  121.  
  122. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  123. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  124. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  125. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  126. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  127. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  128. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  129. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  130. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  131. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  132.  
  133. function sidebar(e:MouseEvent):void{
  134.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  135.     switch (e.target.name){
  136.         case "boton1" :
  137.             indice = 1;
  138.             break;
  139.         case "boton2" :
  140.             indice = 2;
  141.             break;
  142.         case "boton3"  :
  143.             indice = 3;
  144.             break;
  145.         case "boton4" :
  146.             indice = 4;
  147.             break;
  148.         case "boton5" :
  149.             indice = 5;
  150.             break;
  151.         case "boton6" :
  152.             indice = 6;
  153.             break;
  154.         case "boton7" :
  155.             indice = 7;
  156.             break;
  157.         case "boton8" :
  158.             indice = 8;
  159.             break;
  160.         case "boton9" :
  161.             indice = 9;
  162.             break;
  163.         case "boton10" :
  164.             indice = 10;
  165.             break;
  166.     }
  167.     trace(e.target.name)
  168.     trace("indice: "+indice)
  169. }  
  170. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  171.     function sidebarNext(e:MouseEvent):void
  172.     {
  173.         if (indice < numeroDeFotos)
  174.         {
  175.             trace("valor de indice Inicio: "+indice)
  176.             indice++;
  177.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  178.             trace("valor de indice Final: "+indice)
  179.         }
  180.     }
  181.     anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  182.     function sidebarBack(e:MouseEvent):void
  183.     {
  184.         if (indice > 1)
  185.         {
  186.             trace("valor de indice Inicio: "+indice)
  187.             indice--;
  188.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  189.             trace("valor de indice Final: "+indice)
  190.         }
  191.     }
  192.  
  193. muchas gracias por la ayuda¡¡
  #23 (permalink)  
Antiguo 01/11/2011, 14:20
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

no hay otra manera más sencilla de hacerlo con un código más limpio??
  #24 (permalink)  
Antiguo 01/11/2011, 14:48
Avatar de esdebon  
Fecha de Ingreso: agosto-2008
Ubicación: México
Mensajes: 167
Antigüedad: 15 años, 7 meses
Puntos: 18
Respuesta: slide AS3

Cambie tus "if" anidados

Por lo demas se ve bien el codigo, pero sospecho que el problema radica en el prevFrame (); de la funcion atras, es probable que en el frame 1 o en el 2 exista algun codigo que te regrese al frame 3 o re declare posiciones, porque a mi me funciona muy bien tu codigo, solo comente la parte de mascara.play();



Código actionscript:
Ver original
  1. import fl.transitions.Tween;
  2. import fl.transitions.easing.*;
  3.  
  4.  
  5. var arreglo:Array = new Array(0,boton1.x,boton2.x,boton3.x,boton4.x,boton5.x,boton6.x,boton7.x,boton8.x,boton9.x,boton10.x);
  6. var indice:int = 1;
  7. var numeroDeFotos = 10;
  8.  
  9.  
  10.  
  11. stop();
  12.  
  13.  
  14.  
  15. anterior.visible = false;
  16. siguiente.visible = true;
  17.  
  18. siguiente.addEventListener(Event.ENTER_FRAME, mostrar_botones);
  19. function mostrar_botones (e:Event){
  20.    
  21.         anterior.visible = true;
  22.         siguiente.visible = true;
  23.        
  24.         if(indice==1){
  25.             anterior.visible = false;
  26.         }
  27.        
  28.         if(indice==numeroDeFotos){
  29.             siguiente.visible = false;
  30.         }
  31. }
  32.  
  33.  
  34. siguiente.addEventListener(MouseEvent.CLICK, avanzar);
  35. function avanzar (e:MouseEvent){
  36.     nextFrame ();
  37.    // //mascara.play();
  38. }
  39.  
  40. anterior.addEventListener(MouseEvent.CLICK, atras);
  41. function atras (e:MouseEvent){
  42.     prevFrame ();
  43.    // //mascara.play();
  44. }
  45.  
  46.  
  47. boton1.addEventListener(MouseEvent.CLICK, imagen1 );
  48. function imagen1 (e:MouseEvent){
  49.     gotoAndStop(1);
  50.     //mascara.play();
  51. }
  52.  
  53. boton2.addEventListener(MouseEvent.CLICK, imagen2 );
  54. function imagen2 (e:MouseEvent){
  55.     gotoAndStop (2);
  56.     //mascara.play();
  57. }
  58.  
  59. boton3.addEventListener(MouseEvent.CLICK, imagen3 );
  60. function imagen3 (e:MouseEvent){
  61.     gotoAndStop (3);
  62.     //mascara.play();
  63. }
  64.  
  65. boton4.addEventListener(MouseEvent.CLICK, imagen4 );
  66. function imagen4 (e:MouseEvent){
  67.     gotoAndStop (4);
  68.         //mascara.play();
  69.         //mascara.play();
  70. }
  71.  
  72. boton5.addEventListener(MouseEvent.CLICK, imagen5 );
  73. function imagen5 (e:MouseEvent){
  74.     gotoAndStop (5);
  75.     //mascara.play();
  76. }
  77.  
  78. boton6.addEventListener(MouseEvent.CLICK, imagen6 );
  79. function imagen6 (e:MouseEvent){
  80.     gotoAndStop (6);
  81.     //mascara.play();
  82.  
  83. }
  84.  
  85. boton7.addEventListener(MouseEvent.CLICK, imagen7 );
  86. function imagen7 (e:MouseEvent){
  87.     gotoAndStop (7);
  88.     //mascara.play();
  89.  
  90. }
  91.  
  92. boton8.addEventListener(MouseEvent.CLICK, imagen8 );
  93. function imagen8 (e:MouseEvent){
  94.     gotoAndStop (8);
  95.     //mascara.play();
  96. }
  97.  
  98. boton9.addEventListener(MouseEvent.CLICK,imagen9);
  99. function imagen9 (e:MouseEvent){
  100.     gotoAndStop (9);
  101.     //mascara.play();
  102. }
  103.  
  104. boton10.addEventListener(MouseEvent.CLICK, imagen10 );
  105. function imagen10 (e:MouseEvent){
  106.     gotoAndStop (10);
  107.     //mascara.play();
  108. }
  109.  
  110.  
  111. boton1.addEventListener(MouseEvent.CLICK, sidebar);
  112. boton2.addEventListener(MouseEvent.CLICK, sidebar);
  113. boton3.addEventListener(MouseEvent.CLICK, sidebar);
  114. boton4.addEventListener(MouseEvent.CLICK, sidebar);
  115. boton5.addEventListener(MouseEvent.CLICK, sidebar);
  116. boton6.addEventListener(MouseEvent.CLICK, sidebar);
  117. boton7.addEventListener(MouseEvent.CLICK, sidebar);
  118. boton8.addEventListener(MouseEvent.CLICK, sidebar);
  119. boton9.addEventListener(MouseEvent.CLICK, sidebar);
  120. boton10.addEventListener(MouseEvent.CLICK, sidebar);
  121.  
  122. function sidebar(e:MouseEvent):void{
  123.     new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,e.currentTarget.x,1,true);
  124.     switch (e.target.name){
  125.         case "boton1" :
  126.             indice = 1;
  127.             break;
  128.         case "boton2" :
  129.             indice = 2;
  130.             break;
  131.         case "boton3"  :
  132.             indice = 3;
  133.             break;
  134.         case "boton4" :
  135.             indice = 4;
  136.             break;
  137.         case "boton5" :
  138.             indice = 5;
  139.             break;
  140.         case "boton6" :
  141.             indice = 6;
  142.             break;
  143.         case "boton7" :
  144.             indice = 7;
  145.             break;
  146.         case "boton8" :
  147.             indice = 8;
  148.             break;
  149.         case "boton9" :
  150.             indice = 9;
  151.             break;
  152.         case "boton10" :
  153.             indice = 10;
  154.             break;
  155.     }
  156.     trace(e.target.name)
  157.     trace("indice: "+indice)
  158. }  
  159. siguiente.addEventListener(MouseEvent.CLICK, sidebarNext)
  160.     function sidebarNext(e:MouseEvent):void
  161.     {
  162.         if (indice < numeroDeFotos)
  163.         {
  164.             trace("valor de indice Inicio: "+indice)
  165.             indice++;
  166.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  167.             trace("valor de indice Final: "+indice)
  168.         }
  169.  
  170.     }
  171.     anterior.addEventListener(MouseEvent.CLICK, sidebarBack)
  172.     function sidebarBack(e:MouseEvent):void
  173.     {
  174.         if (indice > 1)
  175.         {
  176.             trace("valor de indice Inicio: "+indice)
  177.             indice--;
  178.             new Tween(bar_mc,"x",Strong.easeOut,bar_mc.x,arreglo[indice],1,true);
  179.             trace("valor de indice Final: "+indice)
  180.         }
  181.  
  182.     }
__________________
Mi sitio: http://www.fluocode.com
  #25 (permalink)  
Antiguo 01/11/2011, 15:01
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años
Puntos: 1
Respuesta: slide AS3

solucionado¡¡¡...ya esta¡¡....funciona a la perfeccion¡¡

muchas gracias por tu ayuda y paciencia¡¡...se ve que llevas con esto un tiempecito ya¡...yo al contrario, estoy empezando¡¡

muchas gracias¡un abrazo y saludos dsde España¡

Etiquetas: 3.0, as, cs5, flas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:36.