Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stop();
- /* Milllores realitzades:
- - Tot el contingut es carrega dinàmicament (1 sol frame)
- - Càrrega d'imatges externes
- - Els botons endavant/enrere només es mostren quan és necessari
- - Afegida descripció de la fotografia
- */
- // Inicialitzacions
- var fotoActual = 1;
- foto();
- // Event listeners
- boto1_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
- boto2_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
- boto3_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
- boto4_btn.addEventListener(MouseEvent.MOUSE_UP,boto);
- botoback_btn.addEventListener(MouseEvent.MOUSE_UP,moure);
- botonext_btn.addEventListener(MouseEvent.MOUSE_UP,moure);
- // Funcions
- function moure(event:Event):void{
- // Funció per a controlar els botons d'endavant/enrere
- switch(event.target){
- case botoback_btn:
- fotoActual -= 1;
- foto();
- break;
- case botonext_btn:
- fotoActual += 1;
- foto();
- break;
- }
- }
- function boto(event:Event):void{
- // Funció per a controlar l'accés directe a les imatges
- switch(event.target){
- case boto1_btn:
- fotoActual = 1;
- foto();
- break;
- case boto2_btn:
- fotoActual = 2;
- foto();
- break;
- case boto3_btn:
- fotoActual = 3;
- foto();
- break;
- case boto4_btn:
- fotoActual = 4;
- foto();
- break;
- }
- }
- function foto():void{
- // Funció que fa els canvis segons la fotografia escollida
- if(marcFotos) removeChild(marcFotos);
- var marcFotos = new Loader();
- marcFotos.x = 70; // (midaTotal (640px) - ampleImatge (500px)) / 2
- switch(fotoActual){
- case 1:
- comptador.text = "Foto 1 de 4";
- descripcio.text = "Això és un kiwi. Foto: sxc.hu";
- marcFotos.load(new URLRequest("kiwi.jpg"));
- addChild(marcFotos);
- break;
- case 2:
- comptador.text = "Foto 2 de 4";
- descripcio.text = "Això és una llimona. Foto: sxc.hu";
- marcFotos.load(new URLRequest("llimona.jpg"));
- addChild(marcFotos);
- break;
- case 3:
- comptador.text = "Foto 3 de 4";
- descripcio.text = "Això és raïm. Foto: sxc.hu";
- marcFotos.load(new URLRequest("raim.jpg"));
- addChild(marcFotos);
- break;
- case 4:
- comptador.text = "Foto 4 de 4";
- descripcio.text = "Això són dues pomes. Foto: sxc.hu";
- marcFotos.load(new URLRequest("poma.jpg"));
- addChild(marcFotos);
- break;
- }
- if (fotoActual == 1) botoback_btn.visible = false;
- else botoback_btn.visible = true;
- if (fotoActual == 4) botonext_btn.visible = false;
- else botonext_btn.visible = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement