Hi everyone, I’m new here and here goes with my first post:
I’m working on a website (www.fworks.dk - don’t think the flash file can be seen in FF yet) and I want to load an swf-file with some illustrations and such. As this could get a little big, I have made another swf-file which shows a preloader and loads the first swf-file. The preloader works perfectly when tested in Flash CS3, but when uploaded to and tried on my webhost’s server, the preloader doesn’t load anything. Instead it of the load-percentage it just writes “NaN”.
You can finde the as3-code down below. The preloader-swf and the swf to be loaded are located in the same folder. Both are as3.
I really hope one of you guros can help me. Thanks a lot in advance.
This is the code from my as-class file:
package classes{
// Imports necessary classes
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.*;
import flash.display.Loader;
import flash.display.DisplayObject;
public class LoadBar extends MovieClip {
public function LoadBar() {
// Code starts here
// Defines the initial states of the bar and border
loadBar_mc.scaleX = 0;
loadBorder_mc.visible = false;
// Creates a loader and defines what to load
var loader = new Loader();
loader.load(new URLRequest(“done.swf”));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
addChild(loader);
// Defines what happens when the file has been loaded
function onCompleteHandler(e:Event):void {
loadBar_mc.visible = false;
loadBorder_mc.visible = false;
loadText_txt.visible = false;
}
// Defines what happens while the file is being loaded
function progressHandler(e:ProgressEvent):void {
var percent = (e.bytesLoaded / e.bytesTotal);
loader.visible = true;
loadBar_mc.scaleX = percent;
loadBorder_mc.visible = true;
loadBar_mc.visible = true;
loadText_txt.visible = true;
loadText_txt.text = "Loading environment " + (Math.round(percent * 100)) + “%”;
}
// Code ends here
}
}
}