Could anyone tell me why ON SUBMIT my code isn’t printing back all the questions just the last one? It is suppose to post to PHP all the questions but its only posting the last.
Any suggestions on another way to post or get all user inputed anwers to print or an array or xml list?
<code>
import flash.events.;
import flash.net.;
import flash.display.;
import flash.xml.;
import flash.errors.*;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.FocusEvent;
import com.daniiO.xml.;
import com.daniiO.php.;
//Declair the root XML as XML datatype,
//hint must use same name as root from the XML file.
var survey:XML = <survey/>;
XML.ignoreWhitespace = true;
//setup the loader and loader listeners and functions.
var dateSubmitted:Date = new Date();
var surveyLoader:URLLoader = new URLLoader();
surveyLoader.addEventListener(Event.COMPLETE, onLoadXML);
surveyLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
/var answer0:TextField = new TextField();
var answer1:TextField = new TextField();
var answer2:TextField = new TextField();
var answer3:TextField = new TextField();
var answer4:TextField = new TextField();/
/var questionFields0:TextField = new TextField();
var questionFields1:TextField = new TextField();
var questionFields2:TextField = new TextField();
var questionFields3:TextField = new TextField();
var questionFields4:TextField = new TextField();/
var anslist = new Array ();//= [answer0,answer1,answer2,answer3,answer4];
//load in the XML
var xmlReq:URLRequest = new URLRequest(“surveyPaulsStyle.xml”);
surveyLoader.load(xmlReq);
//what to do now that XML has loaded ;
function onLoadXML(e:Event):void
{
survey = new XML(surveyLoader.data);
//Multi Line arrays and for loops
function showRec():void
{
for (var k:int = 0; k < 5; k++)
{
var questionFields:TextField = new TextField();
questionFields.x = Math.round(10);
questionFields.y = Math.round(5 + 50 * k);
questionFields.height = 20;
questionFields.width = stage.width;
questionFields.multiline = true;
questionFields.wordWrap = true;
questionFields.text = survey.itemList.question. @ question_text[k];
var qz = questionFields.text = survey.itemList.question. @ question_text[k];
addChild(questionFields);
//answers
var answer:TextField =new TextField();
answer.x = Math.round(50);
answer.y = Math.round(20 + 50 * k);
answer.type = TextFieldType.INPUT;
answer.background = true;
answer.border = true;
answer.width = 150;
answer.height = 20;
answer.text = "";
addChild(answer);
for (var i:int =0; i< 5; i++){
var userData = answer.text;
trace(qz + userData);
}
submit.addEventListener(MouseEvent.MOUSE_DOWN, sendData);
function sendData(evt:Event):void{
anslist.push(userData);
var re = qz + userData;
for (var i:int =0; i< 5; i++){
var userData = answer.text;
trace(qz + userData);
}
//trace(answer.text);
//trace(qz + userData);
//trace(anslist);
}}}showRec();}
</code>