package app.vo { import flash.events.EventDispatcher; import flash.events.Event; [Bindable] public class SessionInfo extends EventDispatcher { public var authenticated:Boolean = false; public var username:String = "unknown"; public var viewUsername:String = "unknown"; private var _userId:int; public function get userId():int { return _userId; } public function set userId(userId:int):void { _userId = userId; dispatchEvent(new Event("viewSelfUpdated")); } private var _viewUserId:int; public function get viewUserId():int { return _viewUserId; } public function set viewUserId(viewUserId:int):void { _viewUserId = viewUserId; dispatchEvent(new Event("viewSelfUpdated")); } public function SessionInfo(state:*=null) { if (state != null) { initialize(state.authenticated, state.userId, state.username, state.viewUserId, state.viewUsername); } } public function initialize(authenticated:Boolean, userId:int, username:String, viewUserId:int, viewUsername:String):SessionInfo { this.authenticated = authenticated; this.userId = userId; this.username = username; this.viewUserId = viewUserId; this.viewUsername = viewUsername; return this; } [Bindable(event="viewSelfUpdated")] public function get viewingSelf():Boolean { return userId == viewUserId; } public override function toString():String { return username + ":" + authenticated; } } }