Logical Arrangement of Preloader Script
Hi,
I have created one swf which does following two things;
1. Once it gets loaded in HTML on server it will pass Flashvar to HTML. if flash var from swf and HTML both will match then only swf should play.
2. It will also have Preloader
independently both the scripts work perfectly. But when i compile both in one file then it dosent work in following cases;
Case 1- preloader script first and then flashvar:= this preloads file perfectly but dosent pass flashvar
Case 2- flashvar first and then Preloader:= this works perfectly when i test my file Locally but once i upload it to server then it dosent work for Preloader
what should be my logical sequence or options in this?
I am using "Event.ENTER_FRAME" for Preloder and "Event.COMPLETE" for flashvar...is there any mistake?
//////////////PRELOADER//////////////////
stop();
this.addEventListener(Event.ENTER_FRAME, myMovieLoading);
function myMovieLoading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
preloader_mc.bar_mc.scaleX = loaded/total;
loadInfoText.text = Math.floor((loaded/total)*100)+ "%";
if (total == loaded) {
play();
this.removeEventListener(Event.ENTER_FRAME, myMovieLoading);
}
}
////////////INITIALISING MOVIE///////////////
var keyLoader:URLLoader = new URLLoader();
keyLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
keyLoader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
keyLoader.addEventListener(Event.COMPLETE, loading);
keyLoader.load(new URLRequest("C:/keytext.txt"));
function onLoadError(evt:IOErrorEvent):void
{
loadmyHTML();
}
var myFlashVar:String;
var ver:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (ver in paramObj)
{
myFlashVar = String(paramObj[ver]);
}
function loading(event:Event):void
{
if (keyLoader.data.passKey == "pass1")
{
}
else if (myFlashVar=="pass1")
{
}
else
{
stop();
parent.removeChild(this);
}
}
function loadmyHTML():void
{
if (myFlashVar!="pass1")
{
stop();
parent.removeChild(this);
}
}