-3

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

4

2 回答 2

1

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

于 2012-04-13T00:32:06.640 回答
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('includes/config.inc.php'); mysql_select_db("一些数据库");

$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="first login stage completed"...

于 2012-04-13T08:38:56.610 回答