Load
The Safeloader (security loader) continues to open source.
The following is a load strategy based on speed first , which still has a simple error-correcting mechanism. If you think this is useful, just go for it. Moderator feel that the writing is OK, and I add points, thank you.
Fastloader.as Source code:
/*
* Author Yiao Wei. Flash, Id:hust.
* You can modify and use this code. But please the famous original author, thank you.
* 2006.2.12
* Fast but risky concurrent load mode--fastloader (Fast loader)
*/
Class Loaders. Fastloader
{
private static var Taskarr:array = new Array ();
private static var Mclarr:array = new Array ();
private static var Listarr:array = new Array ();
public static var waitnum:number = 0;
public static var loadednum:number = 0;
public static var loadingnum:number = 0;
public static var totalnum:number = 0;
Private VAR Loader
private static Var Loadid:number;
public static function AddTask (url:string, Target_mc:movieclip)
{
Trace ("AddTask");
Taskarr.push ([URL, target_mc]);
Totalnum + +;
Waitnum + +;
}
private static function preload ()
{
for (Var i=0 i < Taskarr.length i + +)
{
Trace ("i=" + i);
Listarr [i] = new Object ();
Listarr [I].onloadstart = function ()
{
Waitnum--;
Loadingnum + +;
}
Listarr [i].onloadprogress = function ()
{
}
Listarr [i].onloadcomplete = function ()
{
}
Listarr [i].onloadinit = function ()
{
Loadingnum--;
Loadednum + +;
Success,next
Trace ("Onloadinit");
Trace ("i=" + i);
}
Listarr [i].onloaderror = function ()
{
Mclarr [I].loadclip (Taskarr [i][0], Taskarr [i][1]);
}
}
for (var i = 0; i < taskarr.length i + +)
{
Mclarr [i] = new Moviecliploader ();
Mclarr [I].addlistener (Listarr [i]);
}
}
public static function Startload ()
{
Preload ();
Mclarr [0].loadclip (Taskarr [0][0], Taskarr [0][1]);
for (var i = 0; i < taskarr.length i + +)
{
Mclarr [I].loadclip (Taskarr [i][0], Taskarr [i][1]);
}
}
}