我有这个代码用于我遵循的登录教程。
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.*;
/*
create our class
*/
public class login extends MovieClip {
;
public function login ():void {
var login_form:login = new login();
addChild(login_form);
var username:TextField = new TextField();
addChild(username);
var password:TextField = new TextField();
addChild(password);
var login_button:MovieClip = new MovieClip();
addChild(login_button);
/*
buttonMode gives the submit button a rollover
*/
login_button.buttonMode = true;
/*
what this says is that when our button is pressed, the checkLogin function will run
*/
login_button.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);
/*
set the initial textfield values
*/
username.text = "";
password.text = "";
}
public function checkLogin (e:MouseEvent):void {
var username:TextField = new TextField();
addChild(username);
var password:TextField = new TextField();
addChild(password);
/*
check fields before sending request to php
*/
if (username.text == "" || password.text == "") {
/*
if username or password fields are empty set error messages
*/
if (username.text == "") {
username.text = "Enter your username";
}
if (password.text == "") {
password.text = "Enter your password";
}
} else {
/*
init function to process login
*/
processLogin();
}
}
public function processLogin ():void {
var username:TextField = new TextField();
addChild(username);
var password:TextField = new TextField();
addChild(password);
/*
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("php/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);
}
public function showResult (event:Event):void {
var result_text:TextField = new TextField();
addChild(result_text);
/*
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
*/
result_text.autoSize = TextFieldAutoSize.LEFT;
/*
this gets the output and displays it in the result text field
*/
result_text.text = "" + event.target.data.systemResult;
}
}
}
我不确定将所有这些实例放在我的按钮动画片段和文本字段的哪个位置但是当我运行我的程序时,我收到了这个错误。
Error: Error #1023: Stack overflow occurred.
at flash.display::DisplayObject()
at flash.display::InteractiveObject()
at flash.text::TextField()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
at login()
我尝试搜索我能理解但无济于事的答案。任何帮助将不胜感激,谢谢。
答案 0 :(得分:0)
您似乎正在创建login
类的实例并将其添加到自身,这会导致登录构造函数中的无限递归。
var login_form:login = new login();
您应该从另一个对象初始化登录类,并将其添加到舞台上一次。