Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
127 lines (104 sloc) 4.19 KB
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2007 James Ward
http://www.jamesward.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" styleName="plain" name="flex_amf3" xmlns:census2="com.jamesward.census2.*">
<mx:Script>
import com.jamesward.census2.amf.AMFDecoder;
import com.jamesward.census2.amf.AMFPacket;
import com.jamesward.census2.shared.CensusEntryVO;
import mx.controls.Alert;
import mx.utils.URLUtil;
private var startRequestTime:Number;
private var startParseTime:Number;
private var startRenderTime:Number;
private var requestTime:Number;
private var parseTime:Number;
private var renderTime:Number;
private var enableGZip:Boolean = false;
private var censusEntryVO:CensusEntryVO = new CensusEntryVO();
private function sendResults():void
{
var results:Object = {requestTime: requestTime, parseTime: parseTime, renderTime: renderTime, memorySize: System.totalMemory};
for (var k:String in results)
{
var r:URLRequest = new URLRequest(parameters.sendCensusResultURL);
var p:URLVariables = new URLVariables();
p.clientId = parameters.clientId;
p.testId = name;
p.resultType = k;
p.resultData = results[k];
p.gzip = enableGZip;
p.numRows = parameters.numRows;
r.data = p;
var l:URLLoader = new URLLoader();
l.load(r);
}
}
</mx:Script>
<mx:applicationComplete>
<![CDATA[
var amfURL:String = URLUtil.getProtocol(url) +
"://" +
URLUtil.getServerNameWithPort(url) +
"/census2-tests/servlet/CensusServiceServlet?command=getAMF3" +
"&rows=" + parameters.numRows +
"&clientId=" + parameters.clientId +
"&testId=" + name +
"&sendCensusResultURL=" + parameters.sendCensusResultURL +
"&token=" + (new Date()).time;
if ((parameters.enableGZip == null) || (parameters.enableGZip != "false")) // parameters are always strings = lame
{
enableGZip = true;
amfURL += "&gzip=true";
}
var urlReq:URLRequest = new URLRequest(amfURL);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, function(event:Event):void {
var now:Number = new Date().time;
requestTime = now - startRequestTime;
startParseTime = new Date().time;
var ba:ByteArray = (event.currentTarget.data as ByteArray);
var packet:AMFPacket = AMFDecoder.decodeResponse(ba) as AMFPacket;
parseTime = new Date().time - startParseTime;
renderTime = 0;
startRenderTime = (new Date()).time;
dg.dataProvider = packet.messages[0].body;
});
startRequestTime = (new Date()).time;
loader.load(urlReq);
]]>
</mx:applicationComplete>
<census2:FasterSortingDataGrid id="dg" width="100%" height="100%">
<census2:updateComplete>
var now:Number = new Date().time;
if (renderTime == 0)
{
renderTime = now - startRenderTime;
sendResults();
}
</census2:updateComplete>
<census2:columns>
<mx:DataGridColumn dataField="id"/>
<mx:DataGridColumn dataField="age"/>
<mx:DataGridColumn dataField="classOfWorker"/>
<mx:DataGridColumn dataField="education"/>
<mx:DataGridColumn dataField="maritalStatus"/>
<mx:DataGridColumn dataField="race"/>
<mx:DataGridColumn dataField="sex"/>
</census2:columns>
</census2:FasterSortingDataGrid>
</mx:Application>
Something went wrong with that request. Please try again.