问题
I am trying to pass some data between PHP and Flash. In Flash I have managed to get the code below working. The problem is I want to use a relative link such as "data/config.php" however this gives me the following error:
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error.
I tried looking up the error but it seems to have many possible causes and I can't figure out a way around it in my case. Here is the code (this works when the url is absolute):
submit_btn.addEventListener(MouseEvent.CLICK, onClickHandler);
function onClickHandler(event:MouseEvent):void
{
var variables:URLVariables = new URLVariables();
var url_Loader:URLLoader = new URLLoader;
var url_Request:URLRequest = new URLRequest("config.php");
url_Request.method = URLRequestMethod.POST;
url_Request.data = variables;
url_Loader.dataFormat = URLLoaderDataFormat.VARIABLES;
url_Loader.addEventListener(Event.COMPLETE, completeHandler);
variables.uname = uname_txt.text;
variables.sendRequest = "parse";
url_Loader.load(url_Request);
};
function completeHandler(event:Event):void
{
var phpVar1 = event.target.data.var1;
var phpVar2 = event.target.data.var2;
result1_txt.text = phpVar1;
result2_txt.text = phpVar2;
};
回答1:
You do not give enough information to fix your issue. You have an unhandled event.
Error #2044: Unhandled ioError
So why not listen for that event and figure out the issue.
回答2:
If you're using Flex, one option is to build an absolute path with the help of the FlexGlobals.topLevelApplication
object.
You can for example get the URL of the page :
FlexGlobals.topLevelApplication.url
来源:https://stackoverflow.com/questions/16796665/actionscript-3-0-urlrequest-with-relative-link