PDA

View Full Version : Script to modify a database with user variables


chandler124
05-12-2009, 02:32 PM
Hello,

I develop an application in Flex 3.0. This application deals with a database which appears on the application. Actually, the database appears on the Web page and under it there's a form which recover the datas. For example

http://img244.imageshack.us/img244/9571/clich20090512163523.tif (http://img244.imageshack.us/my.php?image=clich20090512163523.tif)
http://img244.imageshack.us/img244/clich20090512163523.tif/1/w320.png (http://g.imageshack.us/img244/clich20090512163523.tif/1/)

Now I made a form like this

http://img21.imageshack.us/img21/976/clich20090512163806.tif (http://img21.imageshack.us/my.php?image=clich20090512163806.tif)
http://img21.imageshack.us/img21/clich20090512163806.tif/1/w320.png (http://g.imageshack.us/img21/clich20090512163806.tif/1/)
Well, when i click on the "OK" button, I would like to put the new datas in the database thanks to the flex app. I don't know how to make the script. Can you help me please ?

Thanks

endergrl
05-12-2009, 03:01 PM
I've always had to do this on the backend. Meaning I use externalInterfae.call to pass variables to javascript which then handles the data and committing it to the db.

tadster
05-12-2009, 03:33 PM
endergrls idea isn't bad if your used to using ajax, or the like, to talk to your server, but you can talk to the server directly from AS3 and mxml.

You'll need to use the flash.net package.. here is an example of sending data to the server:

private function submiter(inp1:String, inp2:String, inp3:String, inp4:String):void
{

var holdresponse:URLLoader = new URLLoader();

//the responsecompute function can be set up to do whatever with the server response
holdresponse.addEventListener(Event.COMPLETE, responsecompute);
//this event for if there is an error
holdresponse.addEventListener(IOErrorEvent.IO_ERRO R, errorsay);

var therequest:URLRequest = new URLRequest("serverpage.aspx");

var varstosend:URLVariables = new URLVariables();

varstosend.oner = inp1;
varstosend.twoer = inp2;
varstosend.threeer = inp3;
varstosend.fourer = inp4;

therequest.data = varstosend;
therequest.method = URLRequestMethod.POST;

holdresponse.load(therequest);

}


this is just a general example of sending data to a server within AS3
hope it helps a bit

in your mxml it can be included within <mx:Script> tags