Número de btn anterior AS2 slideshow

  • cosmic_billion
  • Newbie
  • Newbie
  • Avatar de Usuario
  • Registrado: Nov 05, 2009
  • Mensajes: 14
  • Loc: Amsterdam, the Netherlands
  • Status: Offline

Nota Marzo 12th, 2012, 3:32 am

Hola gente de Ozzu,

¿Cómo está todo el mundo?:)

Hay un gran Action Script slideshow 2/XML código que encontré a través de un enlace en Smashing Magazine, la razón que me gusta es porque tenía una interpolación poco agradable entre imágenes, pero dun dun dun...

He logrado insertar un siguiente, reproducir y pausar botón pero no la función de botón anterior.

La prev_btn se supone que llame la posición actual de la imagen - 1, del mismo modo que el next_btn pide la imagen actual + 1. Esto tiene sentido pero conseguir confundido con algo...


Tu ayuda será aprreciated.

Código: [ Select ]

import gs.*;
import gs.easing.*;


//---Load XML


var xmlPath = "photos.xml";
var photos_xml = new XML();
photos_xml.ignoreWhite = true;
var imageList:Array = new Array();
photos_xml.onLoad = function(success) {
    if (success) { // ----------- load successful
        // ----------- convert XML content to an array
        imageList = photos_xml.firstChild.childNodes;
        // ----------- Do some action once xml is loaded
        loadImage();
        // ----------- Do some action once xml is loaded
    } else {
        // ----------- problem loading, check path
        trace("Error loading photos_xml");
    }
}

//---Load Images


var currentImage:Number = 0;
var imageLoader:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();

imageLoader.addListener(loadListener);

loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
    TweenLite(dot)to(container_mc.background_mc, 1, {_width:target_mc._width + 20, _height:target_mc._height + 20, ease:Strong.easeOut});
    TweenLite(dot)to(container_mc.border_mc, 1, {_width:target_mc._width, _height:target_mc._height, ease:Strong.easeOut});
    TweenLite(dot)to(container_mc.mask_mc, 1, {_width:target_mc._width, _height:target_mc._height, ease:Strong.easeOut});
    
    // center content
    var clipXTarg = Math.round((Stage.width/2)-((target_mc._width+20)/2));
    var clipYTarg = Math.round((Stage.height/2)-((target_mc._height+20)/2));
    TweenLite(dot)to(container_mc, 1, {_x:clipXTarg, _y:clipYTarg, ease:Strong.easeOut});

    // find previous image
    if(currentImage == 0){
        var prevImgNum = imageList.length -1;
    }else{
        var prevImgNum = currentImage -1;
    }
    var prevImg = container_mc.pics_mc["pic"+prevImgNum];
    TweenLite(dot)to(prevImg, 1, {autoAlpha:0, onComplete:removePrevious});
}

loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
    TweenLite(dot)to(target_mc, 1, {autoAlpha:100, delay:1});
    setTimer();
}


//---Functions List


function setTimer(){
    timer = setInterval(loadImage, 5000);
}

function removePrevious(){
    if(prevImg != undefined){
        removeMovieClip(prevImg);
    }
    
    
    // increment the current image
    if(currentImage < imageList.length -1){
        currentImage = currentImage + 1;
    }else{
        currentImage = 0;
    }
}

    //Load the next image automatically
function loadImage(){
    var loadURL = imageList[currentImage].attributes.imgurl;
    var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+currentImage,container_mc.pics_mc.getNextHighestDepth());
    targetClip._alpha = 0;
    clearInterval(timer);


    
    // load the new image
    imageLoader.loadClip(loadURL,targetClip);
}
    //Load the next image if the button was pressed
function loadImagePrevious() {
    if(currentImage == 0){
        var prevImgNum = imageList.length -1;
        
        var loadURL = imageList[prevImg].attributes.imgurl;
        var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+prevImg,container_mc.pics_mc.getNextHighestDepth());
        targetClip._alpha = 0;
        clearInterval(timer);
    
        // load the new image
        imageLoader.loadClip(loadURL,targetClip);
        
    }else{
        var prevImgNum = currentImage - 1;
        var loadURL = imageList[prevImg].attributes.imgurl;
        var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+prevImg,container_mc.pics_mc.getNextHighestDepth());
        targetClip._alpha = 0;
        clearInterval(timer);
    
        // load the new image
        imageLoader.loadClip(loadURL,targetClip);
    }
}


//---On First Load

photos_xml.load(xmlPath);
stop();



//---Buttons


next_mc.onRelease = function() {
    clearInterval(timer);
    timer = setInterval(loadImage, 500);
    pause_mc._visible = true;
    play_mc._visible = false;
}

prev_mc.onRelease = function() {
    clearInterval(timer);
    ????
    pause_mc._visible = true;
    play_mc._visible = false;
    /*if(currentImage == 0){
        var prevImgNum = imageList.length -1;
    }else{
        var prevImgNum = currentImage - 1;
    }
    var prevImg = container_people_mc.pics_mc["pic"+currentImageNumber];
    TweenLite(dot)to(currentImage, 1, {autoAlpha:0, onComplete:removeCurrent});

*/}
  1. import gs.*;
  2. import gs.easing.*;
  3. //---Load XML
  4. var xmlPath = "photos.xml";
  5. var photos_xml = new XML();
  6. photos_xml.ignoreWhite = true;
  7. var imageList:Array = new Array();
  8. photos_xml.onLoad = function(success) {
  9.     if (success) { // ----------- load successful
  10.         // ----------- convert XML content to an array
  11.         imageList = photos_xml.firstChild.childNodes;
  12.         // ----------- Do some action once xml is loaded
  13.         loadImage();
  14.         // ----------- Do some action once xml is loaded
  15.     } else {
  16.         // ----------- problem loading, check path
  17.         trace("Error loading photos_xml");
  18.     }
  19. }
  20. //---Load Images
  21. var currentImage:Number = 0;
  22. var imageLoader:MovieClipLoader = new MovieClipLoader();
  23. var loadListener:Object = new Object();
  24. imageLoader.addListener(loadListener);
  25. loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
  26.     TweenLite(dot)to(container_mc.background_mc, 1, {_width:target_mc._width + 20, _height:target_mc._height + 20, ease:Strong.easeOut});
  27.     TweenLite(dot)to(container_mc.border_mc, 1, {_width:target_mc._width, _height:target_mc._height, ease:Strong.easeOut});
  28.     TweenLite(dot)to(container_mc.mask_mc, 1, {_width:target_mc._width, _height:target_mc._height, ease:Strong.easeOut});
  29.     
  30.     // center content
  31.     var clipXTarg = Math.round((Stage.width/2)-((target_mc._width+20)/2));
  32.     var clipYTarg = Math.round((Stage.height/2)-((target_mc._height+20)/2));
  33.     TweenLite(dot)to(container_mc, 1, {_x:clipXTarg, _y:clipYTarg, ease:Strong.easeOut});
  34.     // find previous image
  35.     if(currentImage == 0){
  36.         var prevImgNum = imageList.length -1;
  37.     }else{
  38.         var prevImgNum = currentImage -1;
  39.     }
  40.     var prevImg = container_mc.pics_mc["pic"+prevImgNum];
  41.     TweenLite(dot)to(prevImg, 1, {autoAlpha:0, onComplete:removePrevious});
  42. }
  43. loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
  44.     TweenLite(dot)to(target_mc, 1, {autoAlpha:100, delay:1});
  45.     setTimer();
  46. }
  47. //---Functions List
  48. function setTimer(){
  49.     timer = setInterval(loadImage, 5000);
  50. }
  51. function removePrevious(){
  52.     if(prevImg != undefined){
  53.         removeMovieClip(prevImg);
  54.     }
  55.     
  56.     
  57.     // increment the current image
  58.     if(currentImage < imageList.length -1){
  59.         currentImage = currentImage + 1;
  60.     }else{
  61.         currentImage = 0;
  62.     }
  63. }
  64.     //Load the next image automatically
  65. function loadImage(){
  66.     var loadURL = imageList[currentImage].attributes.imgurl;
  67.     var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+currentImage,container_mc.pics_mc.getNextHighestDepth());
  68.     targetClip._alpha = 0;
  69.     clearInterval(timer);
  70.     
  71.     // load the new image
  72.     imageLoader.loadClip(loadURL,targetClip);
  73. }
  74.     //Load the next image if the button was pressed
  75. function loadImagePrevious() {
  76.     if(currentImage == 0){
  77.         var prevImgNum = imageList.length -1;
  78.         
  79.         var loadURL = imageList[prevImg].attributes.imgurl;
  80.         var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+prevImg,container_mc.pics_mc.getNextHighestDepth());
  81.         targetClip._alpha = 0;
  82.         clearInterval(timer);
  83.     
  84.         // load the new image
  85.         imageLoader.loadClip(loadURL,targetClip);
  86.         
  87.     }else{
  88.         var prevImgNum = currentImage - 1;
  89.         var loadURL = imageList[prevImg].attributes.imgurl;
  90.         var targetClip = container_mc.pics_mc.createEmptyMovieClip("pic"+prevImg,container_mc.pics_mc.getNextHighestDepth());
  91.         targetClip._alpha = 0;
  92.         clearInterval(timer);
  93.     
  94.         // load the new image
  95.         imageLoader.loadClip(loadURL,targetClip);
  96.     }
  97. }
  98. //---On First Load
  99. photos_xml.load(xmlPath);
  100. stop();
  101. //---Buttons
  102. next_mc.onRelease = function() {
  103.     clearInterval(timer);
  104.     timer = setInterval(loadImage, 500);
  105.     pause_mc._visible = true;
  106.     play_mc._visible = false;
  107. }
  108. prev_mc.onRelease = function() {
  109.     clearInterval(timer);
  110.     ????
  111.     pause_mc._visible = true;
  112.     play_mc._visible = false;
  113.     /*if(currentImage == 0){
  114.         var prevImgNum = imageList.length -1;
  115.     }else{
  116.         var prevImgNum = currentImage - 1;
  117.     }
  118.     var prevImg = container_people_mc.pics_mc["pic"+currentImageNumber];
  119.     TweenLite(dot)to(currentImage, 1, {autoAlpha:0, onComplete:removeCurrent});
  120. */}



Saludos
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Marzo 12th, 2012, 3:32 am

  • ScottG
  • Proficient
  • Proficient
  • No Avatar
  • Registrado: Jul 06, 2010
  • Mensajes: 260
  • Status: Offline

Nota Marzo 14th, 2012, 3:15 pm

¿Vale?.... Como Im mirando este código la parte que todo el trabajo dosis siempre mira hacia atrás...mal explica...el siguiente código encuentra el movieclip el script creado por tomar la imagen actual y quitando 1 también cuando se llama a la función removePrevious también debajo quitar la imagen anterior y agrega a la imagen actual.

ACTIONSCRIPT Código: [ Select ]
loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
/*
I remove most of was not needed to show you
*/
    // find previous image
    if(currentImage == 0){
        var prevImgNum = imageList.length -1;
    }else{
        var prevImgNum = currentImage -1;
    }
    var prevImg = container_mc.pics_mc["pic"+prevImgNum];
    TweenLite(dot)to(prevImg, 1, {autoAlpha:0, onComplete:removePrevious});
}
 
  1. loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
  2. /*
  3. I remove most of was not needed to show you
  4. */
  5.     // find previous image
  6.     if(currentImage == 0){
  7.         var prevImgNum = imageList.length -1;
  8.     }else{
  9.         var prevImgNum = currentImage -1;
  10.     }
  11.     var prevImg = container_mc.pics_mc["pic"+prevImgNum];
  12.     TweenLite(dot)to(prevImg, 1, {autoAlpha:0, onComplete:removePrevious});
  13. }
  14.  


Lo único que puedo pensar con cabo cambiando completamente el código es a la inversa de la matriz de imageList y básicamente hacer una imagen siguiente funcionan como se hizo y la instalación de un intervalo definido para invertir atrás. NO bastante y no sé si funcionará correctamente con pruebas realmente aunque con fuera haciendo una recodificación sobre cómo cambiar las imágenes de su mejor puedo vengo con el momento.
  • cosmic_billion
  • Newbie
  • Newbie
  • Avatar de Usuario
  • Registrado: Nov 05, 2009
  • Mensajes: 14
  • Loc: Amsterdam, the Netherlands
  • Status: Offline

Nota Marzo 19th, 2012, 8:28 am

Ya, no, no su trabajo sin embargo, su realidad cargar la siguiente imagen...Hahaaaaa

Gracias por su respuesta y el esfuerzo ScottG!

Publicar Información

  • Total de mensajes en este tema: 3 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 48 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC