user3283624
user3283624

Reputation: 3

How do i POST a variable value to a php file?

i need to send a variable value from a simple flash program to a php file or my database, i found this code online for that

var loader:URLLoader = new URLLoader();
loader.addEventListener( Event.COMPLETE, completeHandler );
var variables:URLVariables = new URLVariables();
variables.someVar = "someValue";
var request:URLRequest = new URLRequest("myPhpPage.php");
request.method = URLRequestMethod.POST;
request.data = variables
loader.load(request);
function completeHandler( event : Event ) : void{
trace( "finished sending and loading" );
}

but if i make a simple program with one button which raises the value or 'p' by one for every click with the code

on (press) {
i ++;
}

and i put that code for post in the frame actions window i get error messages. One of them is 'The class or identifier 'URLLoader' could not be loaded.' i also can't load URLVariables , Events and URLRequest. Please tell me what i am missing here.

Upvotes: 0

Views: 63

Answers (1)

Boundless
Boundless

Reputation: 2464

Make sure you have the proper imports to use the classes such as URLLoader and URLVariables. Check adobe site to see what package they come from

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html

We see that they all come from the flash.net package. You would want to make sure to import the package like so:

import flash.net.*;

Upvotes: 1

Related Questions