danee987

LoaderMax delay?

Recommended Posts

Hi, was wondering if loader max had a delay property where I could add a delay in between loaders that have been appended if they are loaded sequentially?

 

Something like:

 

var loader:LoaderMax = new LoaderMax({maxConnections:1, delay: 2});

 

loader.append(blablalb);

loader.append(blablal);

 

loader.load();

 

That way in between each loaded file it waits 2 seconds before loading the next. Is this possible?

 

Thanks!

Danny

Share this post


Link to post
Share on other sites

I'm curious why you'd want to do that - usually people want better loading performance (quicker access to their files) rather than having delays. I'm sure you have a good reason, though. To answer your question, no, there isn't a built-in way of doing that besides just using an onComplete to trigger a setTimeout() or delayedCall() that then starts the next loader (you could pause() the LoaderMax and then resume() after the timeout).

Share this post


Link to post
Share on other sites

Hey mate,

 

Something like this should work for you:

public class Main extends MovieClip 
	{
		private var lm:LoaderMax;
		
		public function Main():void 
		{
			//Setup Loadermax instance and set a onChildComplete event for when a 
			lm = new LoaderMax( { onChildComplete:childDone } )
			
			//Add files to Loadermax Queue
			lm.append(new SWFLoader("myFile1.swf", { container:this } ));
			lm.append(new SWFLoader("myFile2.swf", { container:this } ));
			lm.append(new SWFLoader("myFile3.swf", { container:this } ));
			lm.append(new SWFLoader("myFile4.swf", { container:this } ));
			
			//Of course load the queue
			lm.load();
		}
		
		private function childDone(e:LoaderEvent):void 
		{
			//pause the loading
			lm.pause();
			//Wait for 2 sec then resume loading
			TweenLite.delayedCall(2, resumeLoad);
			trace("done")
		}
		
		private function resumeLoad():void
		{
			lm.resume()
		}
	}
  • Like 1

Share this post


Link to post
Share on other sites

Dang it, bet me to it while I was typing Jack:P

Share this post


Link to post
Share on other sites

Thank you guys. I will try this out when I get a chance. It was mainly for testing something. I have an AIR app that I got from a client that runs on Android and has been giving me loading issues (not LoaderMax related). The app contains a very large amount of .swf files that load, each one being around 10kb each. I've had the suspicion that they load so fast it causes the app to hang. So I wanted to slow down the load to see if it helped the issue. Hopefully it will because the client is out of budget to continue to make further changes :/

 

Thank you Jack and Zync!

 

- D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.