?? userview.as.svn-base
字號:
/**
* Project: 用戶可視對象類
* 可視對象 每個類有位置(string),頭像(image),姓名(String),積分(uint),手中牌(Array)
* 可以設(shè)定頭像以及撲克牌 說明信息的位置,分上,下,左,右,四種情況
* Author : dmh2002 http://www.08baby.com/
* Date : 2008.4.8
*/
package com.dmh2002.games.cardgame.cairngorm.view
{
import com.dmh2002.games.cardgame.cairngorm.model.CardGameModelLoactor;
import com.dmh2002.games.cardgame.cairngorm.vo.UserSexVO;
import com.dmh2002.games.cardgame.classes.UserFaceImageClasses;
import com.dmh2002.util.MyRandom;
import mx.containers.Canvas;
import mx.controls.Image;
import mx.controls.Label;
public class UserView extends Canvas
{
[Bindable]
private var _model:CardGameModelLoactor = CardGameModelLoactor.getInstance();
/** 私有屬性 **/
//是否為計算機 true 為是計算機控制
private var _isComputer:Boolean
//用戶名
private var _userName:String
//用戶積分(默認20)
private var _userTotalCent:uint
//用戶游戲局數(shù) 只讀 每一次增減userTotalCent +1
private var _userWinGamesNums:uint=0
private var _userLostGamesNums:uint=0
//用戶性別 僅構(gòu)造函數(shù)中設(shè)定,如果參數(shù)中沒有設(shè)定,則隨機獲取
private var _userSex:String
//用戶頭像 僅構(gòu)造函數(shù)中設(shè)定,如果參數(shù)中沒有設(shè)定,則根據(jù)性別隨機獲取
private var _userFace:Class
//組件設(shè)置
private var _userFaceImage:Image = new Image()
private var _userNameLabel:Label = new Label()
/** get/set 存儲器 **/
//是否為計算機
public function get isComputer():Boolean
{
return this._isComputer
}
public function set isComputer(value:Boolean):void
{
this._isComputer = value
}
//用戶名
public function get userName():String
{
return this._userName
}
public function set userName(value:String):void
{
this._userName = value
this._userNameLabel.text = value
}
//用戶性別
public function get userSex():String
{
return this._userSex
}
//用戶頭像
public function get userFace():Class
{
return this._userFace
}
public function set userFace(value:Class):void
{
this._userFace = value
this._userFaceImage.source = value
}
//用戶積分
public function get userTotalCent():uint
{
return this._userTotalCent
}
public function set userTotalCent(value:uint):void
{
//設(shè)定勝負局數(shù)
if(value>=this._userTotalCent)
this._userWinGamesNums+=1
else
this._userLostGamesNums+=1
this._userTotalCent = value;
}
//用戶游戲勝負局次數(shù)
public function get userWinGamesNums():uint
{
return this._userWinGamesNums
}
public function get userLostGamesNums():uint
{
return this._userLostGamesNums
}
/**
* 構(gòu)造函數(shù)
* 參數(shù) userName String 用戶名
* 參數(shù) isComputer Boolean 是否為計算機 默認 true
* 參數(shù) userSex String 用戶性別 默認 null
* 參數(shù) userFace Class 用戶頭像 默認 null
*/
public function UserView(userName:String,isComputer:Boolean=true,userSex:String=null,userFace:Class=null)
{
super();
//this.setStyle("borderStyle","inset")
//設(shè)置用戶名
this.userName = userName;
//設(shè)置用戶是否為計算機
this.isComputer = isComputer;
//設(shè)置用戶性別
if(userSex == null)
this._userSex = MyRandom.randomExtract(UserSexVO.USER_SEX_ARRAY);
else
this._userSex = userSex;
//設(shè)置用戶頭像 Class
if(userFace == null)
{
var _UserFaceImageClasses:UserFaceImageClasses = new UserFaceImageClasses();
var _UserFaceImageArray:Array = (this._userSex == UserSexVO.USER_SEX_MALE)?
_UserFaceImageClasses.BOY_CLASS_ARRAY:
_UserFaceImageClasses.GIRL_CLASS_ARRAY;
this.userFace = MyRandom.randomExtract(_UserFaceImageArray);
}
else
{
this.userFace = userFace;
}
_userFaceImage.height= _model.User_Faces_Height;
_userFaceImage.width = _model.User_Faces_Width;
_userFaceImage.scaleContent = true;
this.addChild(_userFaceImage);
//添加用戶名label
_userNameLabel.setStyle("color",0x000000)
_userNameLabel.x = _userFaceImage.x
_userNameLabel.y = _userFaceImage.y + _userFaceImage.height - 22
this.addChild(_userNameLabel);
//設(shè)置玩家默認分數(shù)
this._userTotalCent = _model.defaultUserTotalCent;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -