A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] need to find out when all clips are loaded

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] need to find out when all clips are loaded

    Hi,

    I'm trying to have a photo gallery run on its own before allowing the user to stop it and check the pictures by himself on a mouse action or once the preview is done. The code I added to do so is marked out, but it will load the pictures no matter what. I mean without having completely loaded into its container.

    I tried using a conditional statement before the function like so: if(percent == 100) but its ignored by the function. I suppose there is more than one way to solve this, but i guess i need to know when all containers reach the 100 % on loading and that's what I can't figure out.


    Code:
    function loading_function(a:Number):Void {
    	
    	var myLoader:MovieClipLoader = new MovieClipLoader();
    	var myListener:Object = new Object();
    	
    	myListener.onLoadStart = function() {
    	};
    	
    	myListener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
    		percent = Math.floor(bytesLoaded/bytesTotal*100);
    		eval("box"+a).loadBar._visible = true;
    		eval("box"+a).loadBar.gotoAndStop(percent);
    		eval("box"+a+".boxOutline")._alpha = percent;
    	};
    	
    	myListener.onLoadError = function(target:MovieClip) {
    		eval("box"+a)._visible = false;
    	};
    	
    	myListener.onLoadInit = function(target:MovieClip) {
    		//trace("successfully loaded");
    		
    		eval("box"+a).loadBar._visible = false;
    		eval("box"+a)._visible = true;
    		
    		if (a == eval(prevTop+".id")) {
    			eval(prevTop).boxMask._width = eval(prevTop).targetBox._width;
    			eval(prevTop).boxMask._height = eval(prevTop).targetBox._height;
    			eval(prevTop).boxOutline._width = eval(prevTop).targetBox._width;
    			eval(prevTop).boxOutline._height = eval(prevTop).targetBox._height;
    		}
    	};
    	
    		var count:Number = 1;
    		
    		function swapIds():Void {
    			count++;
    			for (i=1; i<=b; i++) {
    				a = count;
    				moveBoxes("box"+a);
    			}
    			
    			if (count == b) {
    				clearInterval(interval_id);
    				restoreIds();
    			}
    			
    			var mouseListener:Object = new Object();
    			mouseListener.onMouseDown = function() {
    				clearInterval(interval_id);
    				Mouse.removeListener(mouseListener);
    				delete count;
    				restoreIds();
    			};
    			Mouse.addListener(mouseListener);
    		}
    		
    		var interval_id:Number = setInterval(swapIds, 2000);
    		
    		function restoreIds():Void {
    			for (i=1; i<=b; i++) {
    				this["box"+i].id = i;
    			}
    		}
    	
    	myLoader.addListener(myListener);
    	myLoader.loadClip("images/Untitled - "+a+".jpg", "box"+a+".targetBox");
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    This will help you with the loading part, sequential loading, one after the other with loadbar scale.

    Basically load them all first one by one then allow your stuff to be done

    Its CS5

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap.

    I received your PM, thanks.

    In the added code I gave, there is a bit you might need to change.

    find
    PHP Code:
    _root["box" j].forceSmoothing true
    and replace it with
    PHP Code:
    _root["box" j].targetBox.forceSmoothing true
    and then the smoothing will work

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