I have created a bean class in action script using flash builder getters and setters method. the class is :`
package defa开发者_Python百科ult{
public class AccountBean
{
private var _username:String;
private var _email:String;
public function get username():String {
return _username;
}
public function set username(value:String):void {
_username = value;
}
public function get email():String {
return _email;
}
public function set email(value:String):void {
_email = value;
}
public function AccountBean() {
}
}
}
How to use set and get methods for this, is this creation of class is correct or not? please help
Yes, it's correct!
var bean:AccountBean = new AccountBean();
//using the setters
bean.username = "Whatever";
bean.email = "bean@whatever.com";
//using the getters
trace( bean.username , bean.email ); // Whatever bean@whatever.com
精彩评论