我目前正在使用 SharedObjects 将用户名和密码保存在 flash cookie 中。我的问题是如何使 usernameField 与 passwordField 匹配,并且 usernameField2 与 passwordField2 匹配。基本上我想区分一个登录集和另一个。
package
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class foo extends Sprite
{
public var usernameField:TextField = new TextField();
public var passwordField:TextField = new TextField();
public var conPasswordField:TextField = new TextField();
public var traceOutputField:TextField = new TextField();
public var saveDataObject:SharedObject = SharedObject.getLocal("test");
public function foo()
{
traceOutputField.width = 500;
addChild(traceOutputField);
usernameField.text = "username";
passwordField.text = "password";
conPasswordField.text = "password";
usernameField.y = 50; addChild(usernameField);
passwordField.y = 100; addChild(passwordField);
conPasswordField.y = 150; addChild(conPasswordField);
registerUserInfo(null);
}
public function registerUserInfo(evt:MouseEvent):void
{
if(passwordField.text == conPasswordField.text)
{
saveDataObject.data.savedUsername = ""+usernameField.text;
saveDataObject.flush();
traceOutputField.text = "DEBUG " + saveDataObject.size + " / " + saveDataObject.data.savedUsername;
saveDataObject.data.savedPassword = ""+passwordField.text;
saveDataObject.flush();
trace(saveDataObject.size);
}
else if(passwordField.text != conPasswordField.text)
{
trace("Passwords do not match");
}
}
}
}