Hello all.
This is my first attempt at sendandload.
I’m sending some data to php file and then returning the results as xml.
Now the best thing about this is it works and i did it. But sometimes the code doesn’t seem to load the data and requires another click on the button. Can anyone explan why this is happening.
Note: ignore the php code it was just to see if i could return the data even though i could do the calculations in flash.
flash code
var myValue:LoadVars = new LoadVars();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
var listArray:Array = new Array();
//
function fillArray() {
for (var i = 0; i<myXML.firstChild.childNodes.length; ++i) {
var rootNode:XMLNode = _root.myXML.firstChild;
_root.listArray* = new Object();
_root.listArray*.cal = rootNode.childNodes*.firstChild.nodeValue;
_root.listArray*.id = rootNode.childNodes*.attributes.id;
}
trace(_root.myXML);
}
//
myXML.onLoad = function() {
_root.chosen = "xml loaded";
fillArray();
};
//
_root.submit_btn.onRelease = function() {
_root.myValue.valueOne = _root.sendMe_mc.valueOne;
_root.myValue.valueTwo = _root.sendMe_mc.valueTwo;
//_root.myValue.valueThree = _root.sendMe_mc.valueThree;
_root.myValue.sendAndLoad("http://myurl/sendAndLoad.php", _root.myXML, "POST");
};
php page:
<?php
$valueOne = urlencode($_POST['valueOne']);
$valueTwo = urlencode($_POST['valueTwo']);
$valuesThree = urlencode($_POST['valueThree']);
function calulate($noOne, $noTwo){
$value = $noOne + $noTwo;
return $value;
}
// echo out data to xml
$xml_output = '<?xml version=\"1.0\"?>';
$xml_output .= '<myXML>';
$i='0';
while ($i <= 10){
$cal =($i * $valueOne) + $valueTwo;
$xml_output .='<entry id="'.$i.'">number '.$cal.'</entry>';
$i++;
}
$xml_output .= '<myXML>';
echo $xml_output;
?>