A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Load Image

  1. #1
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267

    Load Image

    I work with KM. and I made a Gallery, that target the image from URL with LoadMovie and I need a preload for target the image in a mc (container). MovieClipLoader class don´t work in KM. How can I to made a preload for image ? Thanks.

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    MovieClipLoader works I believe.

  3. #3
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Probably, but I not if it exists for AS 1, which I have is AS 2, and does not work in km.
    Mi code Is:
    Code:
    var precargador_mcl:MovieClipLoader = new MovieClipLoader();
    var listener:Object = new Object();
    Stage.showMenu = false;
    listener.onLoadStart = function(target_mc) {
    	trace("Iniciando");
    _root.attachMovie("barra", "barra_mc", _root.getNextHighestDepth());
    _root.barra_mc._y = Stage.height/2;
    _root.barra_mc._x = Stage.width/2;
    };
    listener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
    	trace("En progreso");
    	var porcentaje:Number;
    	porcentaje = Math.round((loadedBytes*100)/totalBytes);
    	_root.barra_mc.gotoAndStop(porcentaje);
    	target_mc._visible = false;
    	target_mc.stop();
    };
    listener.onLoadComplete = function(target_mc) {
    	trace("ya");
    	_root.barra_mc.removeMovieClip();
    	target_mc._visible = true;
    	target_mc.play();
    };
    precargador_mcl.addListener(listener);
    cargar_btn.onRelease = function() {
    	nocache = "?nocaching="+random(65000);
    	precargador_mcl.loadClip("image1.jpg"+nocache, caja_mc);
    };
    Thaks, for you response.

  4. #4
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    AS2 isn't supported by KM.
    If you port the code to AS1 it should work fine since Bret is right. MovieClipLoader is supported and works fine.

  5. #5
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Already I have solved the problem. I still have that the code to purify a bit that it is sure that this slightly dirty, but now it is working perfectly at KM.
    The code is now:
    Code:
    Stage.scaleMode = "noScale";
    //recibe bytes devuleve kb
    function bytes2kb(val){
    	return Math.round(val/1024)
    }
    //holder para el contenido.
    createEmptyMovieClip("holder",1);
    //atachamos el preloader.
    attachMovie("loader","loader",2,{_x:283,_y:229});
    loader.box.autoSize = "right";
    loader.barra._xscale = 1;
    //objeto mcloader
    my_mcl = new MovieClipLoader();
    //listener
    my_mcl_listener = new Object();
    //callback para cuando empieze la carga
    my_mcl_listener.onLoadStart = function(t){	
    	trace("inicia carga");
    	t._visible = false;
    }
    //callback cada vez que se cargue algo
    my_mcl_listener.onLoadProgress = function (t,bl,bt){
    	var p = (bl / bt) * 100
    	loader.box.text = "cargados: " + bytes2kb(bl) + " de " + bytes2kb(bt) + "KB";
    	loader.barra._xscale = p;
    }
    //callback en caso de error
    my_mcl_listener.onLoadError = function (t,ec){
    	trace("ups! error " + ec)
    	loader.box.text = ec;
    }
    //callback para cuando se termina la carga.
    my_mcl_listener.onLoadComplete = function(t){
    	loader._visible = false;
    	t._visible = true;
    	trace("fin de la carga.");
    }
    //agregamos el listener al mcloader
    my_mcl.addListener(my_mcl_listener);
    //cargamos la imagen.
    my_mcl.loadClip("index.swf",holder);
    stop();
    It´s working now yours can see:
    HERE
    Thanks infinites for your attention and I sorry for the coment in this code, it is spanish, that is my language.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center