[virtualcommons-svn] SF.net SVN: virtualcommons:[155] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-09 23:15:45
|
Revision: 155 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=155&view=rev Author: kjonas Date: 2009-06-09 23:15:43 +0000 (Tue, 09 Jun 2009) Log Message: ----------- Added Paths: ----------- mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml Added: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml (rev 0) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:comp="customComponents.*"> + + <comp:ForecastComponent id="forecastComponent" numColumns="15" numBays="3" style="0"/> + + <mx:Script> + <![CDATA[ +// import mx.controls.Alert; +// +// public function init():void +// { +// try +// { +// forecastComponent.initialize(); +// forecastComponent.init(); +// } +// catch(error:Error) +// { +// Alert.show(error.message + "\n" + error.getStackTrace()); +// } +// } + + ]]> + </mx:Script> + +</mx:Application> Added: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-09 23:15:43 UTC (rev 155) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"> + + <mx:VBox id="labels" verticalGap="2"/> + + <mx:DataGrid id="dataGrid" editable="true" enabled="true" dataProvider="dataProvider"/> + + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Label; + import mx.controls.dataGridClasses.DataGridColumn; + + [Bindable] public var dataProvider:ArrayCollection = new ArrayCollection(); + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:Calculated + + public function init():void + { + var newColumnArray:Array = new Array(numColumns); + for(var columnNumber:int=0; columnNumber<newColumnArray.length; columnNumber++) + { + var newDataGridColumn:DataGridColumn = new DataGridColumn(); + newDataGridColumn.draggable = false; + newDataGridColumn.sortable = false; + newDataGridColumn.resizable = false; + newDataGridColumn.width = 30; + + newDataGridColumn.headerText = ""+(columnNumber+1); // 1, 2, 3, ... + newDataGridColumn.dataField = "day"+(columnNumber+1); // day1, day2, day3, ... + + newDataGridColumn.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + + newColumnArray[columnNumber] = newDataGridColumn; + } + dataGrid.columns = newColumnArray; + + var bayNumber:int = 0; + if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing + { + addLabel(); + addLabel("# People in Harbor:"); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# People in Bay " + (bayNumber+1) + ":"); + } + } + else if(style==2) + { + addLabel(); + for(bayNumber=0; bayNumber<numBays; bayNumber++) + { + addLabel("# Fish in Bay " + (bayNumber+1) + ":"); + } + } + } + + public function addLabel(text:String=""):void + { + var newLabel:Label = new Label(); + if(text != "") + { + newLabel.text = text; + } + labels.addChild(newLabel); + } + + ]]> + </mx:Script> + +</mx:HBox> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |