<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="800" height="400" creationComplete="init()" backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
import com.adobe.serialization.json.JSONEncoder;
import mx.controls.Alert;
import com.mo8.data.userNumberRelated;
import com.mo8.man.ModulesAdmin;
import com.mo8.man.RequestController;
import com.mo8.man.RequestAdmin;
import com.mo8.UrlAdress;
import com.mo8.ActionNames;
import com.mo8.utils.shareOperate;
import mx.collections.ArrayCollection;
//[Bindable]
//public var numberCount:ArrayCollection=new ArrayCollection();
private var starttime:String;
private var endtime:String;
public static const NAME:String="userrelatemsg";
[Bindable]
private var uNRAC:ArrayCollection=new ArrayCollection();
private var uNR:userNumberRelated=new userNumberRelated();
private function init():void
{
ModulesAdmin.registModule(NAME,this);
RequestAdmin.addSno(NAME,ActionNames.GET_ONLINE_TOTAL);
}
public function requestBack(key:String,obj:Object):void
{
if(obj.code=="0"){
trace("works here");
if(obj.data.max_online!=0)
{
acAdItems(obj.data.list as Array);
}
else
{
Alert.show("没有列表");
}
//showNaN(obj.data.
}
}
private function acAdItems(a:Array):void
{
var l:uint=a.length;
for(var i:uint=0;i<l;i++){
uNR=new userNumberRelated();
with(uNR){
createtime=a[i].createtime;
online_count=a[i].online_count;
reg_count=a[i].reg_count;
no_role_count=a[i].no_role_count;
role_count=a[i].role_count;
login_count=a[i].login_count;
}
uNRAC.addItem(uNR);
}
stl.text=(uNRAC[0] as userNumberRelated).createtime;
etl.text=(uNRAC[uNRAC.length-1] as userNumberRelated).createtime;
}
private function disEvent(e:Event=null):void
{
//http://xxxxxxxxxxxxxxmanager?action=get_online_total&starttime=20101117000000&endtime=20101124235500&start=0&limit=5
new RequestController().requestURL(UrlAdress.METHOD,UrlAdress.TOTAL_USER_LINEAR_LIST,ActionNames.GET_ONLINE_TOTAL
,"&starttime="+shareOperate.dateFToStr(sd.selectedDate)
+shareOperate.less10Format(shours.value)+shareOperate.less10Format(smins.value)+"00"
+"&endtime="+shareOperate.dateFToStr(ed.selectedDate)+shareOperate.less10Format(ehours.value)
+shareOperate.less10Format(emins.value)+"00"
+"&start="+start.value+"&limit="+limit.value);
}
private function saveData():void
{
var file:File =File.desktopDirectory;
file=file.resolvePath(shareOperate.dateFToStr(sd.selectedDate)
+shareOperate.less10Format(shours.value)+shareOperate.less10Format(smins.value)+
shareOperate.dateFToStr(ed.selectedDate)+shareOperate.less10Format(ehours.value)
+shareOperate.less10Format(emins.value)+".userList");
var fs:FileStream=new FileStream();
fs.open(file,FileMode.WRITE);
fs.writeObject(uNRAC);
fs.close();
mx.controls.Alert.show("已经保存成功");
}
private function openList():void
{
var file:File =new File();
var txtFilter:FileFilter = new FileFilter("用户列表", "*.userList");
try
{
file.browseForOpen("列表文件", [txtFilter]);
file.addEventListener(Event.SELECT, fileSelected);
}
catch (error:Error)
{
trace("Failed:", error.message);
}
}
private function fileSelected(e:Event):void
{
var file:File=e.target as File;
var fs:FileStream=new FileStream();
fs.open(file,FileMode.READ);
uNRAC=fs.readObject() as ArrayCollection;
trace(uNRAC.length);
fs.close();//只剩下此处错误,其他正常
stl.text=(uNRAC[0] as userNumberRelated).createtime;
stl.text=(uNRAC.getItemAt(uNRAC.length-1) as userNumberRelated).createtime;
}
]]>
</mx:Script>
<mx:LineChart y="10" id="linechart1" dataProvider="{uNRAC}" height="337" showDataTips="true" left="200" right="10">
<mx:series>
<!--<mx:LineSeries displayName="createtime" yField="createtime"/>-->
<mx:LineSeries displayName="总在线人数(单独右边坐标)" yField="online_count">
<mx:verticalAxis>
<mx:LinearAxis id="onlineTotal" title="总在线人数(个)"/>
</mx:verticalAxis>
</mx:LineSeries>
<mx:LineSeries displayName="注册人数" yField="reg_count">
<mx:verticalAxis>
<mx:LinearAxis id="msg" title="人数信息(个)"/>
</mx:verticalAxis>
</mx:LineSeries>
<!--由于total的数量比较大,所以单独用一个坐标,其他几个共用一个坐标-->
<mx:LineSeries displayName="无角色人数" verticalAxis="{msg}" yField="no_role_count"/>
<mx:LineSeries displayName="未登录角色数" verticalAxis="{msg}" yField="role_count"/>
<mx:LineSeries displayName="登录人数" verticalAxis="{msg}" yField="login_count"/>
</mx:series>
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="createtime" displayName="创建时间" title="Date" />
</mx:horizontalAxis>
<mx:verticalAxisRenderers>
<mx:AxisRenderer axis="{onlineTotal}" placement="right"/>
<mx:AxisRenderer axis="{msg}" placement="left"/>
</mx:verticalAxisRenderers>
</mx:LineChart>
<mx:Label y="169" text="初始时间" left="10"/>
<mx:Button y="338" label="确定" click="disEvent()" x="65"/>
<mx:Button y="368" label="保存" click="saveData()" x="19"/>
<mx:NumericStepper id="smins" y="252" color="#000000" width="71" maximum="59" minimum="0" stepSize="20" value="0" left="4"/>
<mx:Label y="254" text="分" height="20" left="78"/>
<mx:NumericStepper id="shours" y="222" color="#000000" width="71" maximum="23" minimum="0" value="0" left="4"/>
<mx:Label y="224" text="时" height="20" left="78"/>
<mx:NumericStepper id="ehours" y="220" color="#000000" value="0" width="71" maximum="23" minimum="0" left="107"/>
<mx:NumericStepper id="limit" y="308" color="#000000" width="71" maximum="100000" minimum="0" value="50" left="89"/>
<mx:NumericStepper id="start" y="308" color="#000000" width="71" maximum="10000" minimum="0" left="10"/>
<mx:Label y="222" text="时" height="20" left="181"/>
<mx:NumericStepper id="emins" y="250" color="#000000" width="71" maximum="59" minimum="0" stepSize="20" value="0" left="107"/>
<mx:Label y="252" text="分" height="20" left="181"/>
<mx:Label y="169" text="终止时间" left="107"/>
<mx:DateField y="192" id="sd" x="4" width="82"/>
<mx:DateField y="190" id="ed" left="107"/>
<mx:Label y="282" text="start" left="10"/>
<mx:Label y="282" text="limit" left="89"/>
<mx:Button x="75" y="368" label="打开" click="openList()" width="49"/>
<mx:Legend dataProvider="{linechart1}" left="10" top="10" height="151" width="182"/>
<mx:Text y="355" text="起始时间" id="stl" left="200"/>
<mx:Text y="355" text="终止时间" id="etl" right="60"/>
</mx:Canvas>
转载于:https://www.cnblogs.com/songqiuming/archive/2010/11/26/1888773.html