Tema: slide AS3
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/11/2011, 11:11
david_qko
 
Fecha de Ingreso: marzo-2011
Ubicación: españa
Mensajes: 45
Antigüedad: 13 años, 1 mes
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. }