I am new to AS3, and i am trying to do a search type file in php(to pull info that matches a username) and return the result in AS3. The php returns all variables into AS3, except for the first one that enters,when it loops the second time, all variables passes through ok. I am also trying to do a multiple fields search and return the results in AS3 with similar principles but same issue is occurring. Please help me see if it is a php error or AS3 issue.Thanks for your time
Autoresult.php
<?php
ini_set('display_errors', 1); error_reporting(E_ALL);
session_start();
include 'connect.php';
$username=$_SESSION['username'];
$result=mysqli_query($con,"SELECT * FROM Automatch WHERE username = '$username'")or die( mysqli_error($con));
$solutions = array();
while ($row = mysqli_fetch_assoc($result))
{
print "nobed=".$solutions[0]=$row['nobed'];
print "&zip=".$solutions[1]=$row['zip'];
print "&rangelow=".$solutions[2]=$row['rangelow'];
print "&rangehigh=".$solutions[3]=$row['rangehigh'];
}
?>
BookVo2.as
package com.clark
{
import flash.display.*;
import flash.net.*;
import flash.events.*;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoaderDataFormat;
import flash.net.URLVariables;
public class BookVO2
{
public var nobed:String;
public var zip:String;
public var rangelow:String;
public var rangehigh:String;
public var Bend:URLRequest;
public var variabless:URLVariables;
public var nLoader:URLLoader;
public var callMethod:Function;
public function BookVO2(listener:Function = null) {
Bend = new URLRequest("http://localhost/Autoresult.php");
Bend.method = URLRequestMethod.POST;
variabless = new URLVariables();
Bend.data = variabless;
nLoader = new URLLoader();
nLoader.dataFormat = URLLoaderDataFormat.TEXT;
nLoader.addEventListener(Event.COMPLETE,Jandler);
nLoader.load(Bend);
if (listener != null) {
callMethod = listener;
}
}
public function Jandler(event:Event) {
// handler for the PHP script completion and return of status
var responseVariables:URLVariables = new URLVariables(event.target.data);
nobed = responseVariables.nobed ;
zip = responseVariables.zip;
rangelow = responseVariables.rangelow;
rangehigh = responseVariables.rangehigh;
if (callMethod != null) {
callMethod(this);
}
}
}
}
VectorTest.as
package com.clark
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.display.Sprite;
public class VectorTest extends MovieClip
{
public var books:Vector.<BookVO2>;
public var counter:int = 0;
public function VectorTest()
{
books = new Vector.<BookVO2>();
{
var book:BookVO2 = new BookVO2(response);
books.push(book);
}
}
private function response(book:BookVO2):void
{
trace("Name:",book.nobed);
trace("Zip:", book.zip);
trace("rangelow:", book.rangelow);
trace("rangehigh:", book.rangehigh);
// call finish() if this is the last book.
counter++;
if (counter == books.length) {
finish();
}
}
private function finish():void {
var currentY:int = 270;
for (var k:int = 0; k < books.length; k++)
{
var Bolder:Listing2 = new Listing2();
Bolder.x=80;
var tf:TextField = new TextField();
var tf1:TextField = new TextField();
var tf2:TextField = new TextField();
var tf3:TextField = new TextField();
tf3.width = 100;
tf.defaultTextFormat = new TextFormat("Arial", 12, 0, null, null, null, null, null, TextFormatAlign.CENTER);
tf.width = 100;
tf.autoSize = TextFieldAutoSize.CENTER;
tf1.width = 100;
tf1.autoSize = TextFieldAutoSize.CENTER;
tf2.autoSize = TextFieldAutoSize.CENTER;
tf3.autoSize = TextFieldAutoSize.CENTER;
tf3.width = 100;
tf1.y= tf.height+5;
// Pulling the textfields content out from the current bookVO
tf.text = books[k].nobed;
tf1.text = books[k].zip;
tf2.text = books[k].rangelow;
tf3.text = books[k].rangehigh;
tf1.x = (Bolder.height-tf.height)*.5
tf3.x = (Bolder.height-tf.height)*.5
tf.x = (Bolder.height-tf.height)*.5
tf.y = (Bolder.height-tf.height)*.15
Bolder.addChild(tf);
Bolder.addChild(tf1);
Bolder.addChild(tf2);
Bolder.addChild(tf3);
// position the object based on the accumulating variable.
Bolder.y = currentY;
addChild(Bolder);
currentY += Bolder.height + 35;
}
}
}
}