Skip to main content
Inspiring
October 18, 2011
Question

Logical Arrangement of Preloader Script

  • October 18, 2011
  • 1 reply
  • 756 views

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);

    }

}

This topic has been closed for replies.

1 reply

Participant
October 18, 2011

in your loaded code there is

keyLoader.load(new URLRequest("C:/keytext.txt"));

please see this will not be found on the server thus it may have problem in loading it on serveer while it run local machine. please try replacing the keytext.txt file path to a relative path which can also be found on the server.

hope this would help you,

mohinirajAuthor
Inspiring
October 18, 2011

Hi Jeshu,

I know this file is not present on server and hence i am verifying if it is found or not and if it is not found then i am checking flashvar. please see IoError script its for the same.

Regards,

Mohiniraj

Participant
October 18, 2011

plz tell if u r using all this code in single frame.. or in class base.?