Skip to main content
Known Participant
May 14, 2010
Question

conditional statement for loaded swf

  • May 14, 2010
  • 1 reply
  • 1116 views

I am initiating loading a swf file, "bg1.swf". I have a button that, when clicked, is suppose to check to see if "bg1.swf" is loaded.  I cant figure out how to write the conditional "if" part.  Currently, instead of checking to see if my statement is actually true, it executes loading bg1Req?  Here is the code ...

var bgLoader:Loader = new Loader();

var bg1Req = new URLRequest("bg1.swf");

var bg2Req = new URLRequest("bg2.swf");

bgLoader.load(bg1Req);

this.addChild(bgLoader);

function goSection(event:MouseEvent):void {

     //unload BG Image

     if (bgLoader.load(bg1Req)==true) {

          bgLoader.unloadAndStop();

          bgLoader.load(bg2Req);

          this.addChild(bgLoader);

     }else{

          trace("bg 2 is loaded");

     }

}

btn.addEventListener(MouseEvent.CLICK, goSection);

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 14, 2010

are you trying to create a button that alternately loads bg1.swf and bg2.swf?

Known Participant
May 14, 2010

Not really, this is an abridged version of what I am trying to accomplish.  In a nutshell ... Using a button click, I want to check to see if bg1.swf is loaded, and if so, I want to replace it with bg2.swf.

kglad
Community Expert
Community Expert
May 14, 2010

check the url property of your loader's contentLoaderInfo property.