0

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;
};
  • 2
    The url it looks for is relative to the path of the web page displaying the SWF, not the SWF's location. Unless you have the page and SWF in the same directory, you need to modify the URL to use the web page as the source of the relative path rather than the SWF – Josh May 28 '13 at 19:02

2 Answers2

2

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.

The_asMan
  • 6,364
  • 4
  • 23
  • 34
0

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
duTr
  • 714
  • 5
  • 21