Comunidad de diseño web y desarrollo en internet online

Descargar imagenes Flash con XML

Citar            
MensajeEscrito el 19 Feb 2007 12:06 pm
Hola, tengo una galeria de imagenes que carga las imagenes des de un xml. En el xml hay la ruta de dicha imagen.
Al cargar el flash (la galeria de imagenes), el flash descarga todas las imagenes del xml, y luego va mostrando imagenes segun el usuario va pidiendo.

Al descargar todas las imagenes me coge mucho ancho de banda, y eso no lo quiero.
Quiero que descargue la imagen segun el usuario pida! No todas a la vez, eso es posible?
Como lo puedo hacer?
Sabeis de algun ejemplo que lo cumpla?

Gracias de antemano.
CARMAND

Por Carmand

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 19 Feb 2007 12:48 pm
Una idea, para que se baje un foto especifica, es como hace alguna gente.


Mostrando en un Popup (htm) con la imagen seleccionada....

Por Suriv

131 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Feb 2007 03:05 pm
Guay voy a provarlo! Muchas Gracias... y a ver si encuentro el error.

Por Carmand

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 19 Feb 2007 03:06 pm
Guay voy a provarlo! Muchas Gracias... y a ver si encuentro el error.

Por Carmand

45 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 20 Feb 2007 09:57 am
Bueno este es el codigo que tengo actualmente. A ver de funcionar funciona perfectamente, lo unico es que me carga todas las imagenes al principio y esto se traduce en un augmento muy bestia del ancho de banda de mi servidor a pagar.

Lo que intento hacer es que solo cargue la imagen que el usuario desee, no todas.
Este es el codigo:

Código :

#include "com.qlod.LoaderClass.as"
#include "lmc_tween.as"
loader = new com.qlod.LoaderClass();
loader.setMinSteps(8);
$tweenManager.broadcastEvents = true;
$tweenManager.updateInterval = 5;
//
stop();

gallery = {};
gallery.init = function() {
   this.images = new Array();
   for (i=0; i<llarg; i++) {
      this.images[i] = miXML.firstChild.childNodes[i].attributes.image;
   }
   this.data = [];
   this.resize_controller = {};
   this.resize_controller.clips = [];
   this.isAnimating = true;
   this.imageborder = 6;
   this.timeline = _root;
   this.resizeClip = this.timeline.image_bg_mc;
   this.contentClip = this.timeline.createEmptyMovieClip("image_mc", 500);
   this.centerx = Stage.width/2;
   this.centery = Stage.height/2;
   this.rotateMode = true;
   this.buildNav();
   this.preloadImages();
};

gallery.buildNav = function() {
   var btnsize = 12;
   var navHolder = this.timeline.createEmptyMovieClip("navHolder", 10);
   for (var i = 0; i<this.images.length; i++) {
      var btn = navHolder.attachMovie("imgbtn", "img"+i, i);
      btn._x = btnsize/2+btnsize*i;
      btn.id = i;
      btn.loaded = false;
      btn.onPress = function() {
         gallery.showImage(this.id);
      };
      btn.onRollOver = function() {
         this.over_mc.gotoAndPlay("overanim");
      };
      btn.onRollOut = function() {
         this.over_mc.gotoAndPlay("outanim");
      };
      btn.onLoadStart = function(loaderObj) {
         this.gotoAndPlay("loading");
      };
      btn.onLoadProgress = function() {
         gallery.data[this.id].mc._alpha = 0;
      };
      btn.onLoadComplete = function(success, loaderObj) {
         this.loaded = true;
         gallery.data[this.id].mc._visible = false;
         if (this.id == 0) {
            gallery.showImage(this.id);
         }
      };
      btn.stop();
      var mc = this.contentClip.createEmptyMovieClip("img"+i, i+10);
      this.data[i] = {btn:btn, mc:mc};
   }
   // attach navegador top left
   this.attachClip(navHolder, {center:-navHolder._width/2, top:-12});
};

gallery.preloadImages = function() {
   var gallery = this;
   for (var i = 0; i<this.images.length; i++) {
      loader.load(this.data[i].mc, this.images[i], this.data[i].btn);
   }
};
gallery.showNext = function() {
   this.loadImage(this.currentImageId+1);
};
gallery.showPrev = function() {
   this.loadImage(this.currentImageId-1);
};
gallery.showImage = function(id) {
   if (id>=this.images.length) {
      if (this.rotateMode) {
         id = 0;
      } else {
         return;
      }
   } else if (id<0) {
      if (this.rotateMode) {
         id = this.images.length-1;
      } else {
         return;
      }
   }
   if (this.currentImageId == undefined) {
      this.currentImageId = id;
      this.showNewImage();
   } else {
      if (this.isAnimating) {
         this.nextToShow = id;
      } else {
         this.nextToShow = undefined;
         this.prevImageId = this.currentImageId;
         this.currentImageId = id;
         this.hideOldImage();
      }
   }
};

gallery.hideOldImage = function() {
   trace("hideold"+this.prevImageId);
   this.isAnimating = true;
   this.data[this.prevImageId].mc.alphaTo(0, 1, undefined, 0, {func:this.showNewImage, scope:this});
};

gallery.showNewImage = function() {
   trace("shownew"+this.currentImageId);
   var mc = this.data[this.currentImageId].mc;
   // is loaded
   if (this.data[this.currentImageId].btn.loaded) {
      with (this) {
         contentClip._x = centerx-mc._width/2;
         contentClip._y = centery-mc._height/2;
         this.data[this.prevImageId].mc._visible = false;
         mc._visible = true;
         mc.alphaTo(100, 1, undefined, 1, function () {
            gallery.isAnimating = false;
            trace(gallery.isAnimating);
            if (gallery.nextToShow != undefined) {
               gallery.showImage(gallery.nextToShow);
            }
         });
         var dx = centerx-mc._width/2-imageborder;
         var dy = centery-mc._height/2-imageborder;
         var dw = mc._width+2*imageborder;
         var dh = mc._height+2*imageborder;
         resizeClip.tween(["_x", "_y", "_width", "_height"], [dx, dy, dw, dh], 1, "easeoutexpo");
      }
   } else {
      // break preloading and load mc
      loader.clear();
      // load first the clicked image
      var i = this.currentImageId;
      this.data[i].btn.onLoadComplete = function(success, loaderObj) {
         this.loaded = true;
         gallery.showImage(this.id);
      };
      loader.load(this.data[i].mc, this.images[i], this.data[i].btn);
      // continue the rest
      for (var j = 0; j<this.images.length; j++) {
         if (i != j && !this.data[j].btn.loaded) {
            loader.load(this.data[j].mc, this.images[j], this.data[j].btn);
         }
      }
   }
};

gallery.attachClip = function(mc, alignObj) {
   if (this.resize_controller.clips.length == 0) {
      this.resize_controller.baseClip = this.resizeClip;
      this.resize_controller.onTweenUpdate = function() {
         for (var i in this.clips) {
            var mc = this.clips[i].mc;
            var align = this.clips[i].align;
            if (align.left != undefined) {
               mc._x = align.left+this.baseClip._x;
            } else if (align.center != undefined) {
               mc._x = align.center+this.baseClip._x+(this.baseClip._width/2);
            } else if (align.right != undefined) {
               mc._x = align.right+this.baseClip._x+this.baseClip._width;
            }
            if (align.top != undefined) {
               mc._y = align.top+this.baseClip._y;
            } else if (align.middle != undefined) {
               mc._y = align.middle+this.baseClip._y+(this.baseClip._height/2);
            } else if (align.bottom != undefined) {
               mc._y = align.bottom+this.baseClip._y+this.baseClip._height;
            }
         }
      };
      this.resizeClip.addListener(this.resize_controller);
   }
   this.resize_controller.clips.push({mc:mc, align:alignObj});
   this.resize_controller.onTweenUpdate();
};

gallery.deatachClip = function(mc) {
   for (var i in this.resize_controller.clips) {
   }
};

var miXML:XML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(success:Boolean) {
   llarg = miXML.firstChild.childNodes.length;
   images = new Array(llarg);
   for (i=0; i<llarg; i++) {
      images[i] = miXML.firstChild.childNodes[i].attributes.image;
   }
   gallery.init();
};
miXML.load(mifichero.xml);



A ver si entre todos me podeis ayudar.!! ^^
Se que estoy cerca pero no logro encontrar donde! :)[/code]

Por Carmand

45 de clabLevel



Genero:Masculino  

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.