Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preloader for al swf-s that willl be used

Status
Not open for further replies.

brutteforcce

Technical User
Jun 23, 2006
105
RO
I use a lot in my site a movie clip loader called myMCL. Every time it loads something the preloader is working. Firt I thought that it is a good idea but now I want that preloader to preload all the swf-s that I load using the movie clip loader...

stop();
//--------------------<MCL>-----------------------\\
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();

myMCL.addListener(myListener);

myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
_level50._visible = true;
var preloadPercent:Number = Math.round((loadedBytes / totalBytes) * 100);
_level50.preloader.gotoAndStop(preloadPercent);
}

myListener.onLoadComplete = function(target_mc:MovieClip) {
_level50._visible = false;
}
//--------------------</MCL>-----------------------\\

// trigger the MCL to load these assets:
myMCL.loadClip("trigger.swf", 5);
myMCL.loadClip("preloader.swf", 50);

Please help... Thanks!
 
Thanks a lot and sorry I didn't answered until now ( I was in the hospital ).
So, that script loads the swf-s but it shouldn't. I want to load them all at the begining because then the site should work fast. In the time of the sequential loading the preloader should show the percentage loaded from the grossBytes. Instead of the percentage it could show just something to show the users that it is preloading, the percentage would be nicer but if it is to hard...
In the time of the preloading the preloader should work and after the actions for the loading are given.
An example:
myMCL.loadClip("main_menu.swf", 10);
myMCL.loadClip("initial.swf", 5);
myMCL.loadClip("static.swf", 20);
If it is possible I want this actions to work normally.

If I simulate the download Flash gives me the error with send and don't send...
I have the swf list:
var swfList:Array = ["preloader.swf", "trigger.swf", "main_menu.swf", "initial.swf", "static.swf", "links/link1.swf", "links/link2.swf", "links/link3.swf", "links/link4.swf","submeniu/submeniu1.swf","submeniu/centraleTermice/centrala1.swf"];
I have a lot more to build and add in that list.

I get in the output:
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/preloader.swf
totalBytes: 1170
grossBytes so far: 1170
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/trigger.swf
totalBytes: 1030
grossBytes so far: 2200
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/main_menu.swf
totalBytes: 62906
grossBytes so far: 65106
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/initial.swf
totalBytes: 34754
grossBytes so far: 99860
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/static.swf
totalBytes: 1047
grossBytes so far: 100907
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link1.swf
totalBytes: 65083
grossBytes so far: 165990
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link2.swf
totalBytes: 64501
grossBytes so far: 230491
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link3.swf
totalBytes: 64502
grossBytes so far: 294993
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link4.swf
totalBytes: 64501
grossBytes so far: 359494
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/submeniu1.swf
totalBytes: 13209
grossBytes so far: 372703
***
SWF: file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/centraleTermice/centrala1.swf
totalBytes: 65064
grossBytes so far: 437767
***
Final grossBytes: 437767
***
Start sequential loading
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/preloader.swf
Bytes loaded so far: 1170
0.26%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/preloader.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/trigger.swf
Bytes loaded so far: 2200
0.5%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/trigger.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/main_menu.swf
Bytes loaded so far: 65106
14.87%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/main_menu.swf
***
Currently loading undefined
Bytes loaded so far: 128012
29.24%
***
Load completed for undefined
***
Currently loading undefined
Bytes loaded so far: 134614
30.75%
***
Load completed for undefined
***
Currently loading undefined
Bytes loaded so far: 101954
23.28%
***
Load completed for undefined
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/initial.swf
Bytes loaded so far: 200744
45.85%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/initial.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/static.swf
Bytes loaded so far: 231538
52.89%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/static.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link1.swf
Bytes loaded so far: 360076
82.25%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link1.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link2.swf
Bytes loaded so far: 423995
96.85%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link2.swf
***
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link3.swf
Bytes loaded so far: 437205
99.87%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link3.swf
***
All loadings completed!
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link4.swf
Bytes loaded so far: 502268
114.73%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/links/link4.swf
***
All loadings completed!
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/submeniu1.swf
Bytes loaded so far: NaN
NaN%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/submeniu1.swf
***
All loadings completed!
Currently loading file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/centraleTermice/centrala1.swf
Bytes loaded so far: NaN
NaN%
***
Load completed for file:///C|/Documents%20and%20Settings/brutteforcce/Desktop/SITE/SITE/lucru2/submeniu/centraleTermice/centrala1.swf
***
All loadings completed!

Please help me!

Thanks...
 
K... I am making the site with a friend. I don't have the latest version of it, I will take it today from that friend and I will put the files on the internet...
Thanks a lot!
 
Hi, hope you're recovered fully from your hospital episode!

Unless you post your code I can't be certain but from your output I can tell you're firing "myMCL.loadClip("main_menu.swf", 10);" etc at the same time as sequential loading process.

The problem of that is it messes up the sequential loading monitoring (hence the loading percentage goes beyond 100%).

As for "Currently loading undefined" - it says undefined because you're loading into levels such as "_level10". Why are you using levels? That's Flash 4. If you're developing in Flash 8, NEVER use levels. If you want to load something, create a MovieClip in certain depth (not level) and load into it - that's my sequential loading code is doing. (In fact I think the concept of "level" does not even exist in AS3.)

But if you really want to use your "myMCL.loadClip("main_menu.swf", 10);" etc, then do it after the sequential loading is finished and after you remove the listener object from MovieClipLoader. "main_menu.swf" has been cached during the sequential loading process, it should load instantly.

Kenneth Kawamoto
 
Thanks for the support... I had this code:

Code:
stop();
//--------------------<MCL>-----------------------\\
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();

myMCL.addListener(myListener);

myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
	_level50._visible = true;
	var preloadPercent:Number = Math.round((loadedBytes / totalBytes) * 100);
	_level50.preloader.gotoAndStop(preloadPercent);
}

myListener.onLoadComplete = function(target_mc:MovieClip) {
	_level50._visible = false;
}
//--------------------</MCL>-----------------------\\

// trigger the MCL to load these assets:
myMCL.loadClip("trigger.swf", 5);
myMCL.loadClip("preloader.swf", 50);

//------------------<LoadVars>---------------------\\
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function (success) {
	if (success) {
		_level5.loadedInfo.htmlText = myLV.info;
	} else {
		_level5.loadedInfo.text = "There has been an error loading the requested information. Please contact the Webmaster and report your error.";
	}
}
//------------------</LoadVars>---------------------\\

First I thought that it is a good idea. When a swf is loaded it is preloaded. Now I want to preload all the swf-s at the begining and then the rest of the code should work the same. Maybe the levels aren't the best solution but I used a lot of loading in different levels and I preffer to let it like it is. The next time after learning more I will try not using levels any more.

So I tryed you're code:
Code:
// AS2 main timeline
var swfList:Array = ["preloader.swf", "trigger.swf", "main_menu.swf", "initial.swf", "static.swf","links/link1.swf","links/link2.swf","links/link3.swf","links/link4.swf","submeniu/submeniu1.swf", "submeniu/centraleTermice/centrala1.swf"];
var swfBytesList:Array = new Array();
var loadID:Number = 0;
var isTestLoad:Boolean = true;
var grossBytes:Number = 0;
var bytesCompleted:Number = 0;
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number):Void  {
    if (isTestLoad) {
        if (totalBytes) {
            swfBytesList.push(totalBytes);
            trace("SWF: "+target_mc._url);
            trace("totalBytes: "+totalBytes);
            grossBytes += totalBytes;
            trace("grossBytes so far: "+grossBytes);
            trace("***");
            loadID++;
            if (loadID<swfList.length) {
                testLoad(loadID);
            } else {
                trace("Final grossBytes: "+grossBytes);
                trace("***");
                myMCL.unloadClip(mcTemp);
                mcTemp.removeMovieClip();
                trace("Start sequential loading");
                trace("***");
                isTestLoad = false;
                loadID = 0;
                sequentialLoad(loadID);
            }
        }
    } else {
        trace("Currently loading "+target_mc._url);
        var bytesSoFar:Number = bytesCompleted+loadedBytes;
        trace("Bytes loaded so far: "+bytesSoFar);
        var percentageLoaded:Number = Math.floor(10000*bytesSoFar/grossBytes)/100;
        trace(percentageLoaded+"%");
        trace("***");
    }
};
myListener.onLoadComplete = function(targetMC:MovieClip, httpStatus:Number):Void  {
    bytesCompleted += swfBytesList[loadID];
    trace("Load completed for "+targetMC._url);
    trace("***");
    loadID++;
    if (loadID>=swfList.length) {
        trace("All loadings completed!");
    } else {
        sequentialLoad(loadID);
    }
};
function sequentialLoad(loadID:Number):Void {
    var ID:Number = loadID+1;
    var mc:MovieClip = this.createEmptyMovieClip("mc"+ID, ID);
    myMCL.loadClip(swfList[loadID], mc);
}
function testLoad(loadID:Number):Void {
    mcTemp.removeMovieClip();
    this.createEmptyMovieClip("mcTemp", 1);
    myMCL.loadClip(swfList[loadID], mcTemp);
}
testLoad(loadID);
stop();
//
//------------------<LoadVars>---------------------\\
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function (success) {
	if (success) {
		_level5.loadedInfo.htmlText = myLV.info;
	} else {
		_level5.loadedInfo.text = "There has been an error loading the requested information. Please contact the Webmaster and report your error.";
	}
}
//------------------</LoadVars>---------------------\\

This is on frame 1. I had some loadings on frame 10:
//myMCL.loadClip("main_menu.swf", 10);
//myMCL.loadClip("initial.swf", 5);
//myMCL.loadClip("static.swf", 20);
I dezactivated them and the loading seem to work fine but when I pressed simulate download Flash crashed again.

I would like the code to work like before, just the preloading to be different so the swf-s will load instantly.

I uploaded the site:

master.fla is the site with my preloading, the one I want to change.
master2.fla has to work like master.fla, just that all the preloading should be at the begining and the swf-s should load instantly...

I hope you understand what I want and I really apreciate any help...
Thanks for the help acorded until now and please help me accomplish that site...
 
I think the easiest way is to place my sequential loading script in frame 1 and display whatever you want on Stage (loading bar, percentage, etc - you have enough information to display these things). When the loading is completed, then move onto frame 2, where you can start whatever you were doing - loading SWF into levels, etc. Everything has been already downloaded in the frame 1, whatever you do from frame 2 onwards will happen instantly - that's your aim, isn't it?

Kenneth Kawamoto
 
Thanks... That's what I want, but I can't do it...
I tryed to to this:

Frame 1 Action Script:
Code:
// AS2 main timeline
var swfList:Array = ["preloader.swf", "trigger.swf", "main_menu.swf", "initial.swf", "static.swf","links/link1.swf","links/link2.swf","links/link3.swf","links/link4.swf","submeniu/submeniu1.swf", "submeniu/centraleTermice/centrala1.swf"];
var swfBytesList:Array = new Array();
var loadID:Number = 0;
var isTestLoad:Boolean = true;
var grossBytes:Number = 0;
var bytesCompleted:Number = 0;
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number):Void  {
    if (isTestLoad) {
        if (totalBytes) {
            swfBytesList.push(totalBytes);
            trace("SWF: "+target_mc._url);
            trace("totalBytes: "+totalBytes);
            grossBytes += totalBytes;
            trace("grossBytes so far: "+grossBytes);
            trace("***");
            loadID++;
            if (loadID<swfList.length) {
                testLoad(loadID);
            } else {
                trace("Final grossBytes: "+grossBytes);
                trace("***");
                myMCL.unloadClip(mcTemp);
                mcTemp.removeMovieClip();
                trace("Start sequential loading");
                trace("***");
                isTestLoad = false;
                loadID = 0;
                sequentialLoad(loadID);
            }
        }
    } else {
        trace("Currently loading "+target_mc._url);
        var bytesSoFar:Number = bytesCompleted+loadedBytes;
        trace("Bytes loaded so far: "+bytesSoFar);
        var percentageLoaded:Number = Math.floor(10000*bytesSoFar/grossBytes)/100;
        trace(percentageLoaded+"%");
        trace("***");
    }
};
myListener.onLoadComplete = function(targetMC:MovieClip, httpStatus:Number):Void  {
    bytesCompleted += swfBytesList[loadID];
    trace("Load completed for "+targetMC._url);
    trace("***");
    loadID++;
    if (loadID>=swfList.length) {
        trace("All loadings completed!");
    } else {
        sequentialLoad(loadID);
    }
};
function sequentialLoad(loadID:Number):Void {
    var ID:Number = loadID+1;
    var mc:MovieClip = this.createEmptyMovieClip("mc"+ID, ID);
    myMCL.loadClip(swfList[loadID], mc);
}
function testLoad(loadID:Number):Void {
    mcTemp.removeMovieClip();
    this.createEmptyMovieClip("mcTemp", 1);
    myMCL.loadClip(swfList[loadID], mcTemp);
}
testLoad(loadID);
gotoAndStop(2);
//
You're sequential loading... The swf files preloaded are loaded and they shouldn't be loaded just when the loading in the levels is called...

Frame 2 Action Script:
Code:
myMCL.loadClip("main_menu.swf", 10);
myMCL.loadClip("initial.swf", 5);
myMCL.loadClip("static.swf", 20);
//------------------<LoadVars>---------------------\\
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function (success) {
	if (success) {
		_level5.loadedInfo.htmlText = myLV.info;
	} else {
		_level5.loadedInfo.text = "There has been an error loading the requested information. Please contact the Webmaster and report your error.";
	}
}
//------------------</LoadVars>---------------------\\
This code was on frame 1 and 10... I removed the loading of the preloader.swf and trigger.swf... At the moment I want to see the preloading working and then I will put a preloading bar... trigger.swf is used to load a shared library, when that library is loaded it had to play to frame 10. If the preloading is at the begining, by preloading the trigger.swf the library is loaded?

I get in the output:
Load completed for undefined
Bytes loaded so far: NaN
NaN%
a lot of times, so something isn't working...

Please help me...
Thanks...
 
In the frame 1 script you need to put "stop()" instead of "gotoAndStop(2)" otherwise it just goes to frame 2 without waiting for download is finished!

> The swf files preloaded are loaded and they shouldn't be loaded just when the loading in the levels is called...

I think you're confused what "loading" means. I suppose you're saying they shouldn't be visible until you load them in your levels later. Fine, just set the visible to false or place them off stage. I didn't do that on purpose so that you can actually see them loaded on Stage, but for the final piece obviously you should hide them until you need them.

Kenneth Kawamoto
 
Yes.... That's what I wanted... I set visible to false.
myListener.onLoadComplete = function(targetMC:MovieClip, httpStatus:Number):Void {
targetMC._visible = false;

I put stop at the end and the movie doesn't go to frame 2 so I putted in the list of swf-s the last one trigger.swf.
trigger.swf has the action: _level0.play();
I thought that it will go to frame 2 and it will show the swf in the levels like it supose to...
Flash crashed... I tryed again with some small changes and the loading looked ok but it start repeating the text from the output until Flash crashed... What should I do? Please help...
Thanks...
 
I found out a big mistake... In frame 2 I didn't put the stop... The site works but the preloading doesn't seem to work totally... When I press a button from the menu it should show a swf in a level. It shows it but it is giving in the output:
Currently loading undefined
Bytes loaded so far: NaN
NaN%
***
Load completed for undefined
***
All loadings completed!

The output is:
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/preloader.swf
totalBytes: 2428
grossBytes so far: 2428
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/main_menu.swf
totalBytes: 65398
grossBytes so far: 67826
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/initial.swf
totalBytes: 34754
grossBytes so far: 102580
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/static.swf
totalBytes: 1047
grossBytes so far: 103627
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link1.swf
totalBytes: 65083
grossBytes so far: 168710
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link2.swf
totalBytes: 64501
grossBytes so far: 233211
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link3.swf
totalBytes: 64502
grossBytes so far: 297713
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link4.swf
totalBytes: 64501
grossBytes so far: 362214
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/submeniu1.swf
totalBytes: 13208
grossBytes so far: 375422
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/centraleTermice/centrala1.swf
totalBytes: 65064
grossBytes so far: 440486
***
SWF: file:///E|/salvare/sebi1/site%2Duri/SITE/site/trigger.swf
totalBytes: 123
grossBytes so far: 440609
***
Final grossBytes: 440609
***
Start sequential loading
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/preloader.swf
Bytes loaded so far: 2428
0.55%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/preloader.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/main_menu.swf
Bytes loaded so far: 67826
15.39%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/main_menu.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/initial.swf
Bytes loaded so far: 102580
23.28%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/initial.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/static.swf
Bytes loaded so far: 103627
23.51%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/static.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link1.swf
Bytes loaded so far: 168710
38.29%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link1.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link2.swf
Bytes loaded so far: 233211
52.92%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link2.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link3.swf
Bytes loaded so far: 297713
67.56%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link3.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link4.swf
Bytes loaded so far: 362214
82.2%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/links/link4.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/submeniu1.swf
Bytes loaded so far: 375422
85.2%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/submeniu1.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/centraleTermice/centrala1.swf
Bytes loaded so far: 440486
99.97%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/submeniu/centraleTermice/centrala1.swf
***
Currently loading file:///E|/salvare/sebi1/site%2Duri/SITE/site/trigger.swf
Bytes loaded so far: 440609
100%
***
Load completed for file:///E|/salvare/sebi1/site%2Duri/SITE/site/trigger.swf
***
All loadings completed!
Currently loading undefined
Bytes loaded so far: 506007
114.84%
***
Load completed for undefined
***
All loadings completed!
Currently loading undefined
Bytes loaded so far: NaN
NaN%
***
Load completed for undefined
***
All loadings completed!
Currently loading undefined
Bytes loaded so far: NaN
NaN%
***
Load completed for undefined
***
All loadings completed!
Currently loading undefined
Bytes loaded so far: NaN
NaN%
***
Load completed for undefined
***
All loadings completed!

Please help me...
Thanks...
 
You know where it says "trace("All loadings completed!")", that's where you want to put "gotoAndStop(2)". Also in the same place you want to remove the listener object from MovieClipLoader because you don't want any garbage spat out in the Output after the loading is finished. "myMCL.removeListener(myListener)" should do it.

Kenneth Kawamoto
 
Thanks... So, now I have on frame 1:

Code:
// AS2 main timeline
var swfList:Array = ["preloader.swf", "main_menu.swf", "initial.swf", "static.swf","links/link1.swf","links/link2.swf","links/link3.swf","links/link4.swf","submeniu/submeniu1.swf", "submeniu/centraleTermice/centrala1.swf", "trigger.swf"];
var swfBytesList:Array = new Array();
var loadID:Number = 0;
var isTestLoad:Boolean = true;
var grossBytes:Number = 0;
var bytesCompleted:Number = 0;
var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);
myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number):Void  {
    if (isTestLoad) {
        if (totalBytes) {
            swfBytesList.push(totalBytes);
            trace("SWF: "+target_mc._url);
            trace("totalBytes: "+totalBytes);
            grossBytes += totalBytes;
            trace("grossBytes so far: "+grossBytes);
            trace("***");
            loadID++;
            if (loadID<swfList.length) {
                testLoad(loadID);
            } else {
                trace("Final grossBytes: "+grossBytes);
                trace("***");
                myMCL.unloadClip(mcTemp);
                mcTemp.removeMovieClip();
                trace("Start sequential loading");
                trace("***");
                isTestLoad = false;
                loadID = 0;
                sequentialLoad(loadID);
            }
        }
    } else {
        trace("Currently loading "+target_mc._url);
        var bytesSoFar:Number = bytesCompleted+loadedBytes;
        trace("Bytes loaded so far: "+bytesSoFar);
        var percentageLoaded:Number = Math.floor(10000*bytesSoFar/grossBytes)/100;
        trace(percentageLoaded+"%");
        trace("***");
    }
};
myListener.onLoadComplete = function(targetMC:MovieClip, httpStatus:Number):Void  {
    targetMC._visible = false;
	bytesCompleted += swfBytesList[loadID];
    trace("Load completed for "+targetMC._url);
    trace("***");
    loadID++;
    if (loadID>=swfList.length) {
        trace("All loadings completed!");
		myMCL.removeListener(myListener);
		gotoAndStop(2);
		
	} else {
        sequentialLoad(loadID);
    }
};
function sequentialLoad(loadID:Number):Void {
    var ID:Number = loadID+1;
    var mc:MovieClip = this.createEmptyMovieClip("mc"+ID, ID);
    myMCL.loadClip(swfList[loadID], mc);
}
function testLoad(loadID:Number):Void {
    mcTemp.removeMovieClip();
    this.createEmptyMovieClip("mcTemp", 1);
    myMCL.loadClip(swfList[loadID], mcTemp);
}
testLoad(loadID);

stop();
//

On frame 2:
Code:
//------------------<LoadVars>---------------------\\
var myLV:LoadVars = new LoadVars();

myLV.onLoad = function (success) {
	if (success) {
		_level5.loadedInfo.htmlText = myLV.info;
	} else {
		_level5.loadedInfo.text = "There has been an error loading the requested information. Please contact the Webmaster and report your error.";
	}
}
//------------------</LoadVars>---------------------\\

myMCL.loadClip("main_menu.swf", 10);
myMCL.loadClip("initial.swf", 5);
myMCL.loadClip("static.swf", 20);
stop();

The problem is that it doesn't stop... It is repeating evrything from the begining... Why does it do that?
Please help...
 
> The problem is that it doesn't stop... It is repeating evrything from the begining... Why does it do that?

You should know better than I, but isn't that what you put in one of your SWF? Like "_level0.gotoAndStop(1)" or something? Remove it.

Kenneth Kawamoto
 
I don't find anything like that, so I don't know why is it repeating... Before I used the action for the preloading it worked fine, just that I needed the preloading so it would work the same on the Internet...
Any sugestion?
Please help...
Thanks...
 
It works... When I uploaded the site on the internet I copyed the needed files in a folder and after I continued working in that folder... I copyed the master.fla in the folder from where I copyed the files that I uploaded and it worked. I don't remember making any change to other files instead master.fla in that folder so I don't understand why it worked...
I hope this is my last problem:
Before the preloading of the swf-s that will be used the preloader.swf must be preloaded because it must work correctly in the time of the preloading...
So a message like: "Please wait" should apear when the preloader is preloaded and after it should be visible and it should show the percentage... I hope you understand me and please help me.
Thanks a lot for the help acorded...
 
In the working version it stops, in the other version doesn't stop and the strange thing is that I don't see any difference beetween the 2 versions... They are the same...
What should I do to preload first the preloader?
Thanks...
 
Hi brutteforce,

I can tell it's one (or several) of your external SWFs causing the playhead to go back to frame 1. You just need to go through them to find the culprit. For future reference, avoid using absolute path such as "_root" and "_level0" - they cause problems in situations like this.

As for the preloader for preloader - yes, go for it, but you'll need the preloader for preloader for preloader as well. And the preloader for preloader for preloader for preloader.

I'm joking. The preloader itself should be as small as possible so that you don't need to preload the preloader!!!

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top