Preload an array?

Loading images established in an array in order to decrease load time

Page 1 of 1

1 Replies - 1000 Views - Last Post: 28 February 2009 - 02:51 AM

#1 thegrrraue  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-February 09

Preload an array?

Posted 26 February 2009 - 08:04 PM

So I've got an array of images,

pixArray = ["Images/Architecture/Hospitality/01.jpg", "Images/Architecture/Mixed/01.jpg", "Images/Architecture/Office/01.jpg", "Images/Architecture/Performing/01.jpg"];


It's part of a slide show, loading one image, waiting 4 seconds, then it loads another, etc etc. The problem is, between each image, it has to load.

I'm trying to find a way to get flash to keep loading all the images in the array until they're all loaded, something to the effect of:

on the completion of the loading of the first image, start loading the second image in the array. On completion of loading that, load the third image, etc, until there are no more. I already have a variable that tells it how many items there are as well:

var total:Number = 4;


Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: Preload an array?

#2 thegrrraue  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 26-February 09

Re: Preload an array?

Posted 28 February 2009 - 02:51 AM

For anyone who finds this and needs an answer:

var preClip:MovieClip;
var preLoader:MovieClipLoader;
var preListener:Object;
var preList:Array;

function preload( imageList:Array ):Void
{
	var depth:Number = _root.getNextHighestDepth();
	
	preClip = _root.createEmptyMovieClip( "preClip", depth );
	preLoader = new MovieClipLoader();
	preListener = {
		onloadInit: onloaderInit
	};
	preList = [].concat( imageList );
	
	preLoader.addListener( preListener );
	preLoader.loadClip( preList[ 0 ], preClip );
}

function onloaderInit():Void
{
	preClip._visible = false;
	preList.shift();
	
	if( preList.length )
	{
		preLoader.loadClip( preList[ 0 ], preClip );
	}
	else
	{
		preClip.removeMovieClip();
		preLoader.removeListener( preListener );
		
		preClip = null;
		preLoader = null;
		preListener = null;
		preList = null;
	}
}

preload( pixArray );


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1