Created
May 16, 2012 12:02
-
-
Save liekkas/2709839 to your computer and use it in GitHub Desktop.
RobotLegs:BaseActor 加入数据管理机制
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ultrapower.tomas.cmonitor.common.base | |
{ | |
import flash.utils.Dictionary; | |
import org.robotlegs.mvcs.Actor; | |
/*************************************************************\ | |
* 基础Actor | |
* 数据存放、数据提取、数据清理、当前数据 | |
* | |
* @author liekkas.zeng | |
* @since 2012-04-10 15:27:12 | |
\*************************************************************/ | |
public class BaseActor extends Actor | |
{ | |
/** | |
* 存放数据字典 | |
* */ | |
private var _dataProviderDict:Dictionary = new Dictionary(); | |
/** | |
* 保存数据 | |
* */ | |
public function saveDataToDict(type:String,result:*):void | |
{ | |
if(_dataProviderDict[type]) | |
_dataProviderDict[type] = null; | |
_dataProviderDict[type] = result; | |
trace(" >>> 数据已保存: 类型为 ->" + type); | |
} | |
/** | |
* 提取数据 | |
* */ | |
public function getDataFromDict(type:String):* | |
{ | |
return _dataProviderDict[type]; | |
} | |
/** | |
* 判断数据库里是否有指定类型的值 | |
* */ | |
public function hasValue(type:String):Boolean | |
{ | |
return _dataProviderDict[type] ? true : false; | |
} | |
/** | |
* 清空已保存的数据 | |
* */ | |
public function clearData():void | |
{ | |
for(var key:String in _dataProviderDict) | |
{ | |
_dataProviderDict[key] = null; | |
trace(" >>> 数据已清除:类型为 -> " + key); | |
} | |
} | |
/** | |
* 获取当前类型的信息数据源 | |
* */ | |
protected var _dataProvider:*; | |
public function set dataProvider(value:*):void | |
{ | |
_dataProvider = value; | |
dispatchEvent(); | |
} | |
public function get dataProvider():* | |
{ | |
return _dataProvider; | |
} | |
protected function dispatchEvent():void | |
{ | |
//请覆盖此函数,在这里派发事件 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment