Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-02-2009, 10:22 PM   #1
efficacious
ñøøß
 
Join Date: Oct 2008
Location: US
Posts: 46
Default PHP - Actionscript communications?

Hello all, I'm in need of some help.

I'm trying to get my flash website to basically just talk with php.

I actually have it working atm but it's not working how I want it to.
Currently I use the loadVariables() function to send form values to PHP
and then PHP writes the values to a text file formatted for use within flash.

This works but not effectively. Say if more then one user are using the form?!?

Can anyone show me an EFFECTIVE way to communicate back and forth between flash and php? Please keep in mind that this a multiple SWF flash solution. Different segments of the website are loaded in as the user requests them. And almost all the content is competley dynamic and loaded in as requested by the user.

Ideally I'd like to make a single call to PHP file to both send/recieve values.

\/ Alternate way i'm trying without success
Code:
//OnRelease
Path.SubmitBtn_mc.onRelease = function()
{	
	this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
	loadVariables("http://mysite.com/Pages/PageData/Page3/Forms/form1/request.php", target_mc,"POST");
	
	//Check if we have recieved results back
	function checkParamsLoaded() 
	{
		var counter:Number;
		if (target_mc.EoF == undefined) 
		{
			if(counter>=20)
			{
				clearInterval(param_interval);
				_global.Result = "Failed to recieve return parameters";
				gotoAndPlay("_result");
			}
			else
			{
			trace("Not Yet!.");
			counter++;
			}
		}
		else
		{
			trace("Finished Loading. Killing Check.");
			trace("-------------");
		
			//List off parameters recieved
			for(i in target_mc) 
			{
				trace(i+": "+target_mc[i]);
			}
		
			trace("-------------");
			clearInterval(param_interval);
			
			//Set Result infomation show user.
			_global.Result =  target_mc[1];
			gotoAndPlay("_result");
		}
	}
	var param_interval:Number = setInterval(checkParamsLoaded, 100);
}

//Stop the movie
stop();
The PHP "ECHOS"(If Success)
Code:
&Result=Successfully sent request&EoF=True
Any help somone can offer is appreciated.
efficacious is offline   Reply With Quote
Old 09-03-2009, 01:08 AM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy and Welcome...

Here is the basics you should know to do that...
http://tutorials.flashvacuum.com/ind...ntegration_101
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 09-10-2009, 02:27 AM   #3
efficacious
ñøøß
 
Join Date: Oct 2008
Location: US
Posts: 46
Default

Quote:
Originally Posted by CyanBlue View Post
Howdy and Welcome...

Here is the basics you should know to do that...
http://tutorials.flashvacuum.com/ind...ntegration_101
Ah excellent, thank you. I'll give this tutorial a run through but after skimming it, it does seem to be just what I'm looking for. Amazing I have never found such a simple script before.
efficacious is offline   Reply With Quote
Old 09-10-2009, 01:23 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Glad to help...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 09-10-2009, 03:52 PM   #5
efficacious
ñøøß
 
Join Date: Oct 2008
Location: US
Posts: 46
Default

I've tried this code and it acts like it never sends any variables.
I have my PHP doc setup to accept both POST and GET values.

So that I can test the php file via my browser before telling flash to use it.
Well everytime I do it through my browser it works. Everytime I do it from flash it doesn't work. I don't understand. It's recieving the result that PHP generates but its not sending PHP any variables.

What am I doing wrong....

my code
Code:
Path = _root.LoadedContent_mc.LoadedContent2_mc.Page3_mc.Form_mc.WD_form_mc;

//Intitiate new LoadVars()
result_lv = new LoadVars();
Path._resultTxt.text = "Processing your request...";
	
//Onload event to check for results.
result_lv.onLoad = function(success)
{
	if(success)
	{
		Path._resultTxt.text = result_lv.Result;
		gotoAndPlay(26);
	}
	else
	{
		Path._resultTxt.text = "Error: Loading PHP file!";
	}
}

//This line handles the actual sending/recieving.
result_lv.sendAndLoad("http://mysite.com/Pages/PageData/Page3/Forms/form1/designrequest.php", result_lv, "POST");
efficacious is offline   Reply With Quote
Old 09-10-2009, 04:59 PM   #6
efficacious
ñøøß
 
Join Date: Oct 2008
Location: US
Posts: 46
Default

Ok I thought I got it working but I guess not.

For some reason its saying:

Error: Loading PHP file

Why is it failing to load my php file?
The file is there the address is correct.. I don't get it.

I'm seriously pulling my hair out at this point.

Last edited by efficacious; 09-10-2009 at 05:07 PM.
efficacious is offline   Reply With Quote
Old 09-10-2009, 05:15 PM   #7
efficacious
ñøøß
 
Join Date: Oct 2008
Location: US
Posts: 46
Default

nvm must have been a server glitch or something.. Its working now.

Sigh finally 8)
efficacious is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:37 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.