Loader没有从php中带来变量

时间:2012-04-12 23:24:57

标签: php actionscript-3 variables classloader

我遇到了将变量从php传递到flash文件的问题。它在flash环境中工作得很好但是当我将文件移动到服务器上的实际页面时,加载器似乎没有返回任何值。 任何建议可能会导致什么? 谢谢

2 个答案:

答案 0 :(得分:1)

您还没有提供任何代码,所以这些是我的猜测:

答案 1 :(得分:0)

我没有发布代码的原因是它有点多......

感谢您的帮助

在主要文件中:

function enterLogin(e:MouseEvent):void{
        if(myLogin.inpt_userName.text==""||myLogin.inpt_password.text==""){
        dtf_messenger.text="Please input your username and password.";
        }else{
            dispatchData(myLogin.inpt_userName.text,myLogin.inpt_password.text);
        dtf_messenger.text="First login stage completed.";
        }
}


function dispatchData(userName:String, userPass:String){
        mySendVars.username=userName;
        mySendVars.userpassword=userPass;
        myPostman = new postman(myScriptURL, myDataType, mySendVars);
        myPostman.addEventListener(Event.COMPLETE, showFeedback);
        dtf_messenger.text="Second login stage completed.";
}


function showFeedback(e:Event):void{
dtf_messenger.text="Third login stage completed";
        myGift=e.target.delivery;

}

我的邮递员课程:

包{

import flash.display.MovieClip;
import flash.events.*;
import fl.data.DataProvider;

// classes for server script connection
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.events.IOErrorEvent;



public class postman extends MovieClip{



    public static const VARIABLES:String = "variables";
    public static const TEXT:String = "text";
    public static const BINARY:String = "binary";
    public static const XML_DATA:String = "XML";

    private var myRequest:URLRequest;
    private var myVars:URLVariables;
    public var phpVars:URLVariables;
    private var myLoader:URLLoader;
    private var labelDataType:String;

    public var delivery:Object;
    public var error:Boolean;
    public var boxContent:DataProvider = new DataProvider();


    public function postman(theURL:String, theDataType:String="delivery.VARIABLES", theSendObject:Object=null) {

        myVars = new URLVariables(); // this holds variables to send (as dynamic properties)
        if (theSendObject) {
            for (var i in theSendObject) {
                myVars[i] = theSendObject[i];
            }
        }

        myRequest = new URLRequest();// this prepares the request for the loader
        myRequest.url=theURL;
        myRequest.method=URLRequestMethod.GET;
        myRequest.data=myVars;

        myLoader=new URLLoader();
        myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
        myLoader.addEventListener(Event.COMPLETE, dataDispatched);
        myLoader.load(myRequest);

    }




    public function dataDispatched(e:Event){

            delivery=new URLVariables(e.target.data);
            dispatchEvent(new Event(Event.COMPLETE));

    }
}

}

和我的php:

require_once( '包括/ config.inc.php文件'); mysql_select_db( “somedatabase”);

$userName = $_GET['username'];
$userPassword = sha1($_GET['userpassword']);

$loginQuery="SELECT id, userName, active FROM users WHERE userName='".$userName."' AND pass='".$userPassword."'";
$loginResult=mysql_query($loginQuery, $db);

if(mysql_num_rows($loginResult)==1){
    $row=mysql_fetch_array($loginResult,MYSQL_ASSOC);
    $user_id=$row['id'];
    $user_name=$row['userName'];
    $active=$row['active'];

    if($active==0){

        echo "var0=0&var1=This account hasn't yet been activated.";

    }else{

            setcookie("user_id",$user_id,0,'/','',0);
            setcookie("user_name",$user_name,0,'/','',0);
            echo "var0=1&var1=Welcome ".$userName."!\nYou have been logged in.";
    }


}else{
    echo "var0=0&var1=Incorrect username or password.\nPlease try again.";  

}

mysql_close($db);

所以当我在flash中运行所有这些时,它运行正常。当我在与我的php相同的服务器上上传swf文件时,它只进入第一阶段:dtf_messnger.text =“第一次登录阶段完成”......