1

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);

2 Answers2

1

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.

MakuraYami
  • 3,398
  • 3
  • 16
  • 19
0

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)
{

}
bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
  • Tried it but no difference. The only think I can think of is that I'm referring the php file locally, but right now I've got a problem in my computer so I can't set Apache up and therefore I can't work with localhost. Could the problem be because of the local reference? – Jorge Antonio Díaz-Benito Aug 06 '12 at 12:58
  • .php files in the same folder as the .fla file is this? – bitmapdata.com Aug 06 '12 at 13:09
  • Yes. I know there may be some kind of security issues when trying to modify files in the app folder from the .fla but since the modification is performed from the php file, I don't think that's a problem... – Jorge Antonio Díaz-Benito Aug 06 '12 at 17:02