简体   繁体   中英

How to Debug A SWF file the communicates with localhost

I am trying to debug ActionScript within CS4. The script, as you can see below, is making a GET request to a URL that I am hosting from my machine. When I try to debug the movie I get an message box that says:

Adobe Flash Player has Stopped a potentially unsafe operation. The local application that you are running on your computer: "C:\\myapplication.swf" is trying to make a communicate with this Internet-enabled location:

localhost

To Let this application communicate with the internet click Settings.

So I click settings, and on the Global Security Panel that opens up in my browser, I select Always Allow, close my flash movie and try again. Same error.

Has anyone had this problem?

var requestVars:URLVariables = new URLVariables();
requestVars.ornTest = "test";
var request:URLRequest = new URLRequest();
request.url = "http://localhost/apps/game/tree/DesignFlash.aspx";
request.method = URLRequestMethod.GET;
request.data = requestVars;

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATU S, httpStatusHandler);
loader.addEventListener(SecurityErrorEvent.SECURIT Y_ERROR, securityErrorHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

try
{
  loader.load(request);
}
catch (error:Error)
{
  trace("Unable to load URL");
}

private function loaderCompleteHandler(event:Event):void
{
  var variables:URLVariables = new URLVariables( event.target.data );
  if(variables.success)
  {
  var ornArray = deserializeString(variables.ornData);
  for(var i:int=0;i<ornArray.length;i+=3)
  {
    addOrnamentProperty(ornArray[i],ornArray[i+1],ornArray[i+2]);
  }
      addOrnamentsFromArrayList();
  }
}

You need to add the folder to the list of allowed folders.

Follow this url:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

From the drop down menu that says "Edit Locations..." choose "Add Location..." then browse to the correct directory (the one with the SWF file in it) and add that directory. If your HTML file is in a different directory than the SWF file then I can never recall which one to add so I would add them both.

The other thing you could do is to run your project through a HTTP server running on your own computer. This can be a bit more involved (eg you have to get a HTTP server running and then publish your HTML and SWF to the directory). Adding the folder is the most simple and direct approach but if you use a local server then you won't have any restrictions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM