How do i use this preloader from http://flashscript.biz/MX2004/preloader/preloader_as2.html
//class definition
class FlashscriptLoader {
private static var xDistance:Number;
private static var yDistance:Number;
private static var barHeight:Number;
private static var barColor:Color;
private static var frameName:String;
private static var movieLoader:String;
private static var outLine:String;
private static var perLoaded:Number;
private static var loadedBytes:Number;
private static var totalBytes:Number;
private static var bytes:Number;
private static var frame:Number;
private static var bytesField:String;
private static var frameField:String;
private static var totalField:String;
//constructor
function FlashscriptLoader(xDistance,yDistance,barHeight,barColor,frameName){
loadTheMovie(xDistance,yDistance,barHeight,barColor,frameName);
}
private function loadTheMovie(xDist,yDist,bHeight,bColor,fName):Void{
//passing the parameter variables
xDistance = xDist;
yDistance = yDist;
barHeight = bHeight;
barColor = bColor;
frameName = fName;
//creating empty movieclips for loaderbar
_root.createEmptyMovieClip("outLine",1);
_root.createEmptyMovieClip("movieLoader",2);
//creating the outline for loaderbar
_root.outLine.lineStyle(1, 0x000000, xDist);
_root.outLine.moveTo(xDist-1,yDist-1);
_root.outLine.lineTo(xDist+102,yDist-1);
_root.outLine.lineTo(xDist+102,yDist+bHeight+2);
_root.outLine.lineTo(xDist-1,yDist+bHeight+2);
_root.outLine.lineTo(xDist-1,yDist-1);
//creating textfields
_root.createTextField("bytesField",3,xDist-70,yDist+bHeight+20,100,15);
_root.bytesField.textColor = "0xffffff";
_root.createTextField("frameField",4,xDist+90,yDist+bHeight+20,100,15);
_root.createTextField("totalField",5,xDist+20,yDist+bHeight+50,100,15);
//loading function
_root.onEnterFrame = function() {
//getting total bytes
totalBytes = _root.getBytesTotal();
//loded bytes defining
loadedBytes = _root.getBytesLoaded();
//bytes loaded
bytes = Math.ceil((loadedBytes/1024)*1000);
//% loaded
perLoaded = Math.ceil((loadedBytes/totalBytes) * 100);
//defining the loading status for loaderbar
frame = Math.ceil(loadedBytes/(totalBytes/100)+xDist);
//creating the fill for loaderbar
_root.movieLoader.lineStyle(1, bColor, xDist);
_root.movieLoader.beginFill(bColor,xDist);
_root.movieLoader.moveTo(xDist,yDist);
_root.movieLoader.lineTo(frame,yDist);
_root.movieLoader.lineTo(frame,yDist+bHeight);
_root.movieLoader.lineTo(xDist,yDist+bHeight);
_root.movieLoader.lineTo(xDist,yDist);
//showing the bytes and % loaded in textfield
_root.totalField.text = "total bytes: "+totalBytes;
_root.bytesField.text = "bytes loaded: "+bytes;
_root.frameField.text = "% loaded: "+perLoaded;
//after loading remove all objects and go to indicated frame
if (loadedBytes >= totalBytes) {
removeMovieClip(_root.movieLoader);
removeMovieClip(_root.outLine);
removeMovieClip(_root.bytesField);
removeMovieClip(_root.frameField);
removeMovieClip(_root.totalField);
_root.gotoAndPlay(fName);
delete _root.onEnterFrame;
}
}
}
}
then use it with -
stop();
var myLoader:FlashscriptLoader = new FlashscriptLoader(x,y,height,color,"framename");
But where do i put the main code??
Thanks,
Josh.