并非所有加载器都适用于Flash AS3

时间:2014-01-15 12:28:16

标签: actionscript-3 flash

您好我一直致力于一些需要登录系统的项目。我现在把它链接到数据库,问题是其他装载机在我的系统中没有工作请帮助!在此先感谢:)

当我点击登录和注册时,它工作正常,并转到diff .swf文件的指定链接:

但登录后,这些服务器按钮无法在链接的.swf上运行

这是我的代码:

package 
{

/*
    always extend a class using movieclip instead of sprite when using flash.
    */

import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;



public class main extends MovieClip {;

var loadit = new Loader();



public function main():void
{



    /*
                buttonMode gives the submit button a rollover
                */

    submit_button.buttonMode = true;
    register_button.buttonMode = true;
    quit_button.buttonMode = true;
    server1_button.buttonMode = true;
    server2_button.buttonMode = true;
    /*
                what this says is that when our button is pressed, the checkLogin function will run
                */

    submit_button.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);
    quit_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoLogin);
    register_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoRegister);
    server1_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoLobby);
    server2_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoLobby);

    /*
                set the initial textfield values
                */

    username.text = "";
    password.text = "";

}

    function gotoLobby(event:MouseEvent)
{
    trace("you clicked me");
    loadit = new Loader();// here it is instantiated
    addChild(loadit);
    loadit.load(new URLRequest("lobby.swf"));
}

function gotoLogin(event:MouseEvent)
{
    trace("you clicked me");
    loadit = new Loader();// here it is instantiated
    addChild(loadit);
    loadit.load(new URLRequest("login.swf"));
}


function gotoRegister(event:MouseEvent)
{
    trace("you clicked me");
    loadit = new Loader();// here it is instantiated
    addChild(loadit);
    loadit.load(new URLRequest("register.swf"));

}


/*
function to process our login
*/

public function processLogin():void
{

    /*
        variables that we send to the php file
        */

    var phpVars:URLVariables = new URLVariables();

    /*
        we create a URLRequest  variable. This gets the php file path.
        */

    var phpFileRequest:URLRequest = new URLRequest("http://localhost/Perdigana/controlpanel.php");

    /*
        this allows us to use the post function in php
        */

    phpFileRequest.method = URLRequestMethod.POST;

    /*
        attach the php variables to the URLRequest
        */

    phpFileRequest.data = phpVars;

    /*
        create a new loader to load and send our urlrequest
        */

    var phpLoader:URLLoader = new URLLoader();
    phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    phpLoader.addEventListener(Event.COMPLETE, showResult);

    /*
        now lets create the variables to send to the php file
        */

    phpVars.systemCall = "checkLogin";
    phpVars.username = username.text;
    phpVars.password = password.text;

    /*
        this will start the communication between flash and php
        */

    phpLoader.load(phpFileRequest);

}

/*
function to show the result of the login
*/

public function showResult(event:Event):void
{

    /*

        this autosizes the text field

        ***** You will need to import flash's text classes. You can do this by adding: 

        import flash.text.*;

        ...to your list of import statements 

        */

    status.autoSize = TextFieldAutoSize.LEFT;

    /*
        this gets the output and displays it in the result text field
    */

    status.text = "" + event.target.data.systemResult;
    if (event.target.data.systemResult != "Incorrect username or password. Please try again!")
    {
        status.visible = false;
        username.visible = false;
        password.visible = false;
        username_lbl.visible = false;
        password_lbl.visible = false;
        password_lbl.visible = false;
        password_lbl.visible = false;
        register_button.visible = false;
        submit_button.visible = false;
        server1_button.visible = true;
        server2_button.visible = true;
        server3_button.visible = true;
        quit_button.visible = true;



    }
}

/*
        the function to checkLogin
        */

public function checkLogin(e:MouseEvent):void
{

    if (username.text == "" || password.text == "")
    {

        /*
                if username or password fields are empty set error messages
                */

        if (username.text == "")
        {

            status.text = "Please enter your username";
            status.visible = true;

        }
        else if (password.text == "")
        {

            status.text = "Please enter your password";
            status.visible = true;

        }

    }
    else
    {
        processLogin();
    }

}

}



}

当我点击服务器时,他们得到了正确的输出,因为“你点击了我”,但请保留在那个swf上请帮助!

0 个答案:

没有答案