Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2.  
  3. /* Milllores realitzades:
  4.     - Tot el contingut es carrega dinàmicament (1 sol frame)
  5.     - Càrrega d'imatges externes
  6.     - Els botons endavant/enrere només es mostren quan és necessari
  7.     - Afegida descripció de la fotografia
  8. */
  9.  
  10. // Inicialitzacions
  11. var fotoActual = 1;
  12. foto();
  13.  
  14. // Event listeners
  15. boto1_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
  16. boto2_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
  17. boto3_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
  18. boto4_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
  19. botoback_btn.addEventListener(MouseEvent.MOUSE_UP,moure);
  20. botonext_btn.addEventListener(MouseEvent.MOUSE_UP,moure);
  21.  
  22. // Funcions
  23. function moure(event:Event):void{
  24.     // Funció per a controlar els botons d'endavant/enrere
  25.     switch(event.target){
  26.         case botoback_btn:
  27.             fotoActual -= 1;
  28.             foto();
  29.             break;
  30.         case botonext_btn:
  31.             fotoActual += 1;
  32.             foto();
  33.             break;
  34.     }
  35. }
  36.  
  37. function boto(event:Event):void{
  38.     // Funció per a controlar l'accés directe a les imatges
  39.     switch(event.target){
  40.         case boto1_btn:
  41.             fotoActual = 1;
  42.             foto();
  43.             break;
  44.         case boto2_btn:
  45.             fotoActual = 2;
  46.             foto();
  47.             break;
  48.         case boto3_btn:
  49.             fotoActual = 3;
  50.             foto();
  51.             break;
  52.         case boto4_btn:
  53.             fotoActual = 4;
  54.             foto();
  55.             break;
  56.     }
  57. }
  58.  
  59. function foto():void{
  60.     // Funció que fa els canvis segons la fotografia escollida
  61.     if(marcFotos) removeChild(marcFotos);
  62.     var marcFotos = new Loader();
  63.     marcFotos.x = 70; // (midaTotal (640px) - ampleImatge (500px)) / 2
  64.     switch(fotoActual){
  65.         case 1:
  66.             comptador.text = "Foto 1 de 4";
  67.             descripcio.text = "Això és un kiwi. Foto: sxc.hu";
  68.             marcFotos.load(new URLRequest("kiwi.jpg"));
  69.             addChild(marcFotos);
  70.             break;
  71.         case 2:
  72.             comptador.text = "Foto 2 de 4";
  73.             descripcio.text = "Això és una llimona. Foto: sxc.hu";
  74.             marcFotos.load(new URLRequest("llimona.jpg"));
  75.             addChild(marcFotos);
  76.             break;
  77.         case 3:
  78.             comptador.text = "Foto 3 de 4";
  79.             descripcio.text = "Això és raïm. Foto: sxc.hu";
  80.             marcFotos.load(new URLRequest("raim.jpg"));
  81.             addChild(marcFotos);
  82.             break;
  83.         case 4:
  84.             comptador.text = "Foto 4 de 4";
  85.             descripcio.text = "Això són dues pomes. Foto: sxc.hu";
  86.             marcFotos.load(new URLRequest("poma.jpg"));
  87.             addChild(marcFotos);
  88.             break;
  89.     }
  90.     if (fotoActual == 1) botoback_btn.visible = false;
  91.     else botoback_btn.visible = true;
  92.     if (fotoActual == 4) botonext_btn.visible = false;
  93.     else botonext_btn.visible = true;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement