Problems with preloading external swfs
Hello
I have to make a website using Flash CS3 and ActionScript 3. I decided to set up a main.swf with a menu which loads all other pages (external swfs) into a movieclip. During the loading process a preloader is shown. This works fine until you click on a button for a page during another one is still loading. Allthough the percent counter refreshs and the swf you requested last gets loaded and dsiplayed, the preloader doesn´t turn invisible and stops above 100 %.
Please can anyone help me? Do I have to chose a totally different approach?
The code on frame 1:
var swfLoader:Loader = new Loader();
// sets the movieclip conbox as place for the external swfs
conbox.addChild(swfLoader);// all external swfs
var homeURL:URLRequest = new URLRequest("Unterseiten/home.swf");
var home2URL:URLRequest = new URLRequest("Unterseiten/home2.swf");// the EventListener
swfLoader.contentLoaderInfo.addEventListener(Event.OPEN, loadStart);
swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
// loads the first external swf on start up
swfLoader.load(homeURL);// the functions
function loadStart(e:Event):void {
var percentLoaded = 0;
}function loadProgress(event:ProgressEvent):void
{
var percentLoaded:Number = event.bytesLoaded / event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
this.percentLoaded.text = String(uint(percentLoaded)) + "%";
this.USLadetext.visible = true;
this.percentLoaded.visible = true;
}
function loadProdComplete(e:Event):void {
trace("file loaded");
this.USLadetext.visible = false;
this.percentLoaded.visible = false;
}
The code for a button:
[button1.addEventListener(MouseEvent.MOUSE_UP, onBtn1Release);
function onBtn1Release(e:MouseEvent):void{
swfLoader.load(home2URL);
}
