动态创建多个共享对象

creating multiple sharedobject dynamically

我想动态创建多个共享对象来创建多登录,为此我使用了以下代码。但如果有任何办法,它会抛出 error.Please post。

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++;
}

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

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