swflist = new Array("bg.swf","nav.swf","content.swf")
loadingswfNum = -1
checkLoad = false
this.createEmptyMovieClip("loadertest_mc",100)
this.createEmptyMovieClip("targetClip_mc",101)
function loadClip(){
var swfNum++
if (swfNum < swflist.length){
var cliptoload = swflist[loadingswfNum]
targetClip_mc.loadMovie(cliptoload )
loadertest_mc.hasLoaded = false
loadertest_mc.onEnterFrame = checkloadfunc
}else{
loadertest_mc.removeMovieClip()
targetClip_mc.removeMovieClip()
_root.gotoAndPlay("allclipsLoaded")
}
}
checkloadfunc (){
var bl = this._parent.targetClip_mc.getBytesLoaded()
var bt = this._parent.targetClip_mc.getBytesTotal()
var bp = int((100/bt)*bl)
if (bp>=100 && this._parent.targetClip._width >0 && bl > 4 && hasLoaded == false ){
hasLoaded = true
this._parent.loadClip()
}
}
loadClip()
stop()
- swflist = new Array("bg.swf","nav.swf","content.swf")
- loadingswfNum = -1
- checkLoad = false
- this.createEmptyMovieClip("loadertest_mc",100)
- this.createEmptyMovieClip("targetClip_mc",101)
- function loadClip(){
-
- var swfNum++
- if (swfNum < swflist.length){
- var cliptoload = swflist[loadingswfNum]
- targetClip_mc.loadMovie(cliptoload )
- loadertest_mc.hasLoaded = false
- loadertest_mc.onEnterFrame = checkloadfunc
- }else{
- loadertest_mc.removeMovieClip()
- targetClip_mc.removeMovieClip()
- _root.gotoAndPlay("allclipsLoaded")
- }
- }
- checkloadfunc (){
- var bl = this._parent.targetClip_mc.getBytesLoaded()
- var bt = this._parent.targetClip_mc.getBytesTotal()
- var bp = int((100/bt)*bl)
- if (bp>=100 && this._parent.targetClip._width >0 && bl > 4 && hasLoaded == false ){
- hasLoaded = true
- this._parent.loadClip()
-
- }
- }
- loadClip()
- stop()
put this on a say first frame.
If you want a loading animation add a movieclip with a looping anim.
if you dont want to see the content loading in then position the target_mc off stage or invisible.
loadclip will load the swfs in the array.
i create 2 empty clips. one to load the clip into and the other to check its loaded amount.
the onEnterframe function has a "if" condition that makes sure at least some of the content is loaded, that it has loaded it and also theres a check to make sure the clip has appear on stage (the _width > 0). You only really need this for jpgs if you want them 100% visible before you say mask them in or something. All you really need is
bp>=100 && bl > 4 && hasLoaded == false
i have the bl (bytes loaded) because sometimes bl and bt might register as 0 or undefined which can cause problems.
the hasloaded is to stop you from calling loadclip multiple times.
When all clips are loaded it will tidy up the created clips and goto whatever lable you require
loadertest_mc.removeMovieClip()
targetClip_mc.removeMovieClip()
_root.gotoAndPlay("allclipsLoaded")
- loadertest_mc.removeMovieClip()
- targetClip_mc.removeMovieClip()
- _root.gotoAndPlay("allclipsLoaded")
probably will need a little refining as i haven't tested it.