📄 userview.as
字号:
/**
* Project: 用户可视对象类
* 可视对象 每个类有位置(string),头像(image),姓名(String),积分(uint),手中牌(Array)
* 可以设定头像以及扑克牌 说明信息的位置,分上,下,左,右,四种情况
* 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
//用户游戏局数 只读 每一次增减userTotalCent +1
private var _userWinGamesNums:uint=0
private var _userLostGamesNums:uint=0
//用户性别 仅构造函数中设定,如果参数中没有设定,则随机获取
private var _userSex:String
//用户头像 仅构造函数中设定,如果参数中没有设定,则根据性别随机获取
private var _userFace:Class
//组件设置
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
{
//设定胜负局数
if(value>=this._userTotalCent)
this._userWinGamesNums+=1
else
this._userLostGamesNums+=1
this._userTotalCent = value;
}
//用户游戏胜负局次数
public function get userWinGamesNums():uint
{
return this._userWinGamesNums
}
public function get userLostGamesNums():uint
{
return this._userLostGamesNums
}
/**
* 构造函数
* 参数 userName String 用户名
* 参数 isComputer Boolean 是否为计算机 默认 true
* 参数 userSex String 用户性别 默认 null
* 参数 userFace Class 用户头像 默认 null
*/
public function UserView(userName:String,isComputer:Boolean=true,userSex:String=null,userFace:Class=null)
{
super();
//this.setStyle("borderStyle","inset")
//设置用户名
this.userName = userName;
//设置用户是否为计算机
this.isComputer = isComputer;
//设置用户性别
if(userSex == null)
this._userSex = MyRandom.randomExtract(UserSexVO.USER_SEX_ARRAY);
else
this._userSex = userSex;
//设置用户头像 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);
//设置玩家默认分数
this._userTotalCent = _model.defaultUserTotalCent;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -