Comunidad de diseño web y desarrollo en internet online

Banner con imagenes desde base de datos y fade _alpha ::

Citar            
MensajeEscrito el 04 May 2006 11:51 pm
hola a todos esto es un llamamiento a todo aquel que me pueda echar una manita a sacar este quebradero de cabeza a buen puerto.

este ladrillo de a continuacion se trata de un script que yo trato de usarlo para
cargar unos links de una base de datos e introducirlos en un array, para manejarlos al crear movie clips dinamicamente y cargar las imagenes en ellos, hasta aqui todo muy bonito.

el problema me dio cuando meti la funcion control.onEnterFrame dentro de la funcion newImage ya los links no funcionan y cuando funcionan no me hace el efecto del fade a alpha

a ver si alguno me echa un cable.. :cry: llevo var:Number horas=5*24;//sin dormir

ya suenio con el :| codigo

Código :


/////////////////////////////////////////////////////////////START
trace("START THE GAME");

//recogemos imagenes en un array
var misImagenes=new Array();

for(i=0;i<dat.num_imgs;i++){
    //en esta direccion no estan las fotos pero vamos cargo las fotos de esta manera
   misImagenes.push("http://www.clickandclick.com/"+eval("dat.img"+i));
   trace("a "+misImagenes[i]);
}
/* 
var newImageCreated=0;
for(i=0;i<dat.num_imgs;i++){
   //creamos un movieclip vacio para cargar la imagen
   this.createEmptyMovieClip("imageContainer"+i,i);
   //cargamos una imagen ciclicamente
   loadMovie(misImagenes[i],"imageContainer"+i);
   var fieldName=eval("imageContainer"+i);
   this.fieldName._x=10*i;
   this.fieldName._y=10*i;
   //increment in 1 the variable newImageCount
   newImageCreated++;
   trace("newImageCount  "+newImageCreated);
   trace(this.getNextHighestDepth());
}
*/

//SETUP newImage function /* */
/////////////////////////////////////////////////////////////START
var imageLoaded=0;
var clipPath="image"+imageLoaded;
var imageArrayPath=eval("misImagenes");
var newImageCounter=0;

//nuevo clip control para controlar la carga de container
var freeDepth= 0;trace("despues de control: "+freeDepth);

//comienzo de la funcion newImage
var newImage=function(){
   trace("/////////////// SETUP AREA 2 //////////////////");
   trace("clip: DENTRO DE LA FUNCI "+clip);
   trace("imageLoaded: "+imageLoaded);
   trace("clipPath: "+clipPath);
   trace("/////////////// SETUP AREA 2 //////////////////");
   //create container mc
   this.createEmptyMovieClip(eval("image_mc"+imageLoaded),imageLoaded);
   trace("JODER"+eval("_root.image_mc"+imageLoaded))
   
   
   // SETUP ///this is to preload the image and make the alpha/////////////START
   // here set the image to load
   var image=misImagenes[imageLoaded];
   trace("JODERimage= "+image );//uncomment to see +info in process
   var clip ="_root.image_mc"+imageLoaded;//we choose here the clip to apply the fader
   trace("JODERclip= "+clip );
   clip._alpha=0;//set mc alpha in 0 to normal // set at 100 to intermitent fader
   clip.loadMovie("image"+imageLoaded);//we load the image on to the clip here
   var i=0;// non touch this line is a counter and must be 0
   var alphaValue=100;//we choose our preferred finish alpha value
   var vel=10; // 1 slow - 10 medium - 20 fast
   //////////////////////////////////////////////////////////////////////////////
   //we create the clip "control" to make the preloader
   this.createEmptyMovieClip("control",10000);
   
   //control.onEnterFrame_Function//helper_new_timeline//
   control.onEnterFrame=function(){ 
    if (clip.getBytesLoaded()==clip.getBytesTotal() and clip.getBytesLoaded()>4){ 
   //trace("LOADED");//uncomment to see +info in process
         //resize
         //clip._width = 184;
         //clip._height = 240;
         delete this.onEnterFrame;//stop process this.onEnterFrame
         
         //running fader//
      //trace("comienza el fader");//uncomment to see +info in process
      this.onEnterFrame = function (){
   if (clip._alpha<=alphaValue){
   clip._alpha = (i++)*vel;
   }else{
      delete this.onEnterFrame;//stop process this.onEnterFrame
      //trace("termino el fader");//uncomment to see +info in process
      //put here the code you want to run when the fader finish
      stop();
          }
      };
      } 
   };
   
   //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\///////////////////\\\\\FINISH
   
   trace('imagen a cargar'+imageArrayPath[imageLoaded]);
   trace("showme FREE DEPTH PLEASE: "+freeDepth)
   
   imageLoaded++;
   freeDepth++;
      
//depuracion   
trace("actualizado num_imgs: "+dat.num_imgs);   
trace("newImage created");
trace("image created number : "+ newImageCounter);
//
if(newImageCounter>=dat.num_imgs-1){
   clearInterval(imageCreator);
   swaper = setInterval(swap,5000);
}
newImageCounter++;

}

///////////////////FUNCION newImage FINISH.


//comienzo de la funcion swapdepths
var swap=function(){
   
   trace("_root. : "+_root);
   trace("_root.container : "+_root.container);
   trace("_root.control : "+_root.control);
   trace("_root.container.image : "+_root.container.image1);
   trace("_root.container.image : "+_root.container.image2);
   trace("_root.container.image : "+_root.container.image3);
   trace("_root.container.image : "+_root.container.image4);
   trace("_root.container.image : "+_root.container.image5);
   trace("_root.container.image : "+_root.container.image6);
   
   trace("swaping depths");   
   
}


//set interval for imageCreator newImage function
if(newImageCounter < (dat.num_imgs.length)){
   trace("eoooonum_imgs: "+dat.num_imgs);
   trace("newImageCounter: "+ newImageCounter);
   
   imageCreator= setInterval(newImage,10000);
   
}




//invoke the function
newImage();

   

/////////////////////////////////////////////////////////////FINISH




stop();




gracias a todo el mundo 8)

Por elkenny

28 de clabLevel



 

salamanca

safari
Citar            
MensajeEscrito el 05 May 2006 12:32 pm
Creo que debes tratar de segmentar el código y en el caso de que encuentres un problema lo recrees en un ejemplo sencillo y pequeño (para que sea más facil poder ayudarte).
Recordá que un problema bien planteado es practicamente una solución en puerta. Saludos.

Por micheloud

341 de clabLevel



 

Misiones, Argentina

unknown

 

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