PDA

View Full Version : Problem sending info from Flash to PHP


stevenS.
03-20-2008, 04:58 PM
Hey there, so I'm creating this voting thing in Flash that would send the info to a PHP file and then onto a database. I'm not working on the PHP though, just the flash side. The problem is that he's saying he isn't able to receive the info still. So my question is what kind of PHP coding should he use to receive it from my Flash file. Here's the actionscript:

var myLv:LoadVars = new LoadVars();
var resultArray:Array = ["empty"];
var totalPressed:Number = 0;

stop();
for (i=1;i<13;i++) {
this["box"+i].id = i;
this["box"+i].onRelease = function() {
judgeAmount(this,this.id);
};
resultArray.push(0);
};

function judgeAmount(box:MovieClip,idNo:Number):Void {
if (box._currentframe == 2) {
totalPressed--;
resultArray[idNo] = 0;
this["box"+idNo].voting = 0;
box.gotoAndStop(1);
}
else {
if (totalPressed < 6) {
box.gotoAndStop(2);
resultArray[idNo] = 1;
this["box"+idNo].voting = 1;
totalPressed++;
}
};
if (totalPressed == 6)
{
submit._alpha = 100;
submit.enabled = true;
}
else
{
submit._alpha = 0
submit.enabled = false;
}
}
submit.onRelease = function():Void

{
sendVars();
_root.gotoAndStop(2);
}

myLv.onLoad = function():Void
{
trace("data sent");
}
function sendVars():Void
{
var len:Number = resultArray.length;
for (i=1;i<len;i++)
{
myLv["var"+i]=resultArray[i];
}
myLv.sendAndLoad("myphp.php",myLv,"POST");
}

To clarify a little more, does he need to be writing code that would receive information for every movieclip of the boxes people vote for, or for the array that the Flash file is sending out? And what might that code look like so I can advise him on it? I'm guessing it would be a sort of $_POST kind of thing...

Any help would be greatly appreciated! Thanks so much!

atomic
03-20-2008, 05:56 PM
This might help?

http://tutorials.flashvacuum.com/index.php?show=Flash_PHP_Integration_101

stevenS.
03-20-2008, 06:21 PM
Hmm, thanks for the reply but it doesn't really help me. It seems that one is just sending the variables inside of the loadVar and variables are defined, but in mine it's sending the results from the result array and the variables aren't defined...

Maybe I need to tell him to get data from the sendVar that's being sent from my Flash file? :confused: