动态创建多个共享对象

时间:2017-02-23 09:50:26

标签: actionscript-3 flash shared-objects

我想动态创建多个sharedobject来创建多重登录,我使用下面的代码。但它会引发错误。如果有任何办法,请发帖。

var k:Number=0;
var signup:SharedObject = SharedObject.getLocal("newSignUp");

signup_mc.signup_btn.addEventListener(MouseEvent.CLICK, signupcheck);

function signupcheck(event:MouseEvent):void {
newusername = signup_mc.username_txt.text;
    newpassword = signup_mc.password_txt.text;
    signup.data.nwusername+k = newusername;
    signup.data.nwpassword+k = newpassword; 
    signup.flush();
k++;
}

1 个答案:

答案 0 :(得分:0)

肯定会有错误。我想,在大多数语言中分配+ b = c都是错误的。如果你想要像nwusername0,nwusername1等密钥,你需要以正确的方式创建密钥:

signup.data["nwusername" + k] = newusername;
signup.data["nwpassword" + k] = newpassword;