Php或AS3错误?错误#2007:参数文本必须为非null

时间:2013-11-19 14:46:41

标签: php actionscript-3 flash

我是AS3的新手,我正在尝试在php中执行搜索类型文件(以提取与用户名匹配的信息)并将结果返回到AS3。 php将所有变量返回到AS3,除了第一个输入,当它第二次循环时,所有变量都通过ok。 我也尝试进行多字段搜索并在AS3中返回具有类似原理的结果,但同样的问题正在发生。请帮我看看它是php错误还是AS3问题。谢谢你的时间

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;
            }

        }

    }

}

2 个答案:

答案 0 :(得分:0)

尝试类似的东西:

tf.text = books[k].nobed || '';
tf1.text = books[k].zip || '';
tf2.text = books[k].rangelow || '';
tf3.text = books[k].rangehigh || '';

或者这个:

tf.text = "";
if ( books[k].nobed !== null ) tf.text = books[k].nobed;
etc...

答案 1 :(得分:0)

声明variabless = new URLVariables();

as

var variables:URLVariables = new URLVariables();

实例化varibles好友。