Question

I've got an actionscript code supposed to run a php script which, to make sure the error is not on it but on the AS code, I've reduced to creating a plain text file. After the line supposed to call the php script, I've got a call to 'trace' in order to make sure that the line is run. Given this, looks like 'the script is run', but there's no new file.

Here's the important code:

AS

const iURL:String = "i.php";
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest(iURL));

php

$ourFileName = "playlistTEST.xml";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle,"CREATED");
fclose($ourFileHandle);
Was it helpful?

Solution

You could try adding event.complete on your AS code

var myRequest:URLRequest = new URLRequest("http:// ... /i.php");
myLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onLoad);
myLoader.load(myRequest);

function onLoad(evt:Event):void
{
    trace(myLoader.data);
}

Also did you open the php file though the browser yet? You should probably test that first before calling it with AS.

Remember that AS uses normal HTTP request method, so the result is the same as when you open it in the browser.

OTHER TIPS

refer a following code.

var urlRequest:URLRequest = new URLRequest("http://...php");
urlRequest.method = URLRequestMethod.GET;

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.load(urlRequest);

function onCompleteHandler(e:Event)
{

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top