[virtualcommons-svn] SF.net SVN: virtualcommons:[165] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-17 23:30:49
|
Revision: 165 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=165&view=rev Author: kjonas Date: 2009-06-17 23:29:38 +0000 (Wed, 17 Jun 2009) Log Message: ----------- ForecastingFishQuestionC.mxml and ForecastingPeopleQuestionC.mxml are component representations of the two original forecasting components the recalculate function needs to be fixed once the ForecastingFishQuestionC.mxml has access to necessary information Changing values in the first dataGrid does, however, force updating of the calculated dataGrid through use of updater and updaterObject Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as Modified: mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/FisheryExperimentKalin.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -182,7 +182,9 @@ { if(content.numChildren == 0) { return false; } + var obj:DisplayObject = content.getChildAt(0); + var returnValue:Boolean = false; if(obj is SocioDemographicPage) { @@ -200,7 +202,11 @@ Alert.show(info.getYear());*/ Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); // Alert.show("Before invoking createstudent()"); - return true; + + btnBack.enabled = true; + btnForward.enabled = true; + + returnValue = true; } } if(obj is InstructionPage_TEMP) @@ -211,11 +217,11 @@ expiredContent.addChild(obj); currentState = "none"; //consumer.subscribe(); - return true; + returnValue = true; } } - return false; + return returnValue; } Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,19 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" initialize="init()"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*" xmlns:quest="customComponents.questions.*" + initialize="init()"> <mx:VBox id="content" minWidth="160"> - - <qComp:ForecastComponent id="forecastComponent0" numColumns="15" numBays="3" style="0" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent1" numColumns="15" numBays="3" style="1" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent2" numColumns="6" numBays="3" style="2" minimumWidth="{content.minWidth}"/> - <qComp:ForecastComponent id="forecastComponent3" numColumns="6" numBays="3" style="3" minimumWidth="{content.minWidth}"/> - <mx:HBox> - <mx:Button label="Save" click="save()"/> - <mx:Button label="Load" click="load()"/> - </mx:HBox> - - <quest:StrategyDesignQuestionC id="planner"/> - + <quest:ForecastingPeopleQuestionC id="people"/> + <mx:Button label="Save" click="save()"/> + <mx:Button label="Load" click="load()"/> + <quest:ForecastingFishQuestionC id="fish" initialize="false"/> </mx:VBox> <mx:Script> @@ -21,30 +14,21 @@ import mx.collections.ArrayCollection; import mx.controls.Alert; - public var forecastSaved:ArrayCollection = null; - public var plannerSaved:ArrayCollection = null; + public var peopleSaved:ArrayCollection = null; + public var fishSaved:ArrayCollection = null; -// try -// { -// -// } -// catch(error:Error) -// { -// Alert.show(error.message + "\n" + error.getStackTrace()); -// } - public function init():void { - + people.initialize(); + people.init(); } public function save():void { try { - forecastSaved = forecastComponent0.save(); - - plannerSaved = planner.save(); + peopleSaved = people.save(); + fishSaved = fish.save(); } catch(error:Error) { @@ -56,12 +40,8 @@ { try { - forecastComponent0.load(forecastSaved); - forecastComponent1.load(forecastSaved); - forecastComponent2.load(forecastSaved); - forecastComponent3.load(forecastSaved); - - planner.load(plannerSaved); + people.load(peopleSaved); + fish.load(fishSaved,peopleSaved); } catch(error:Error) { Added: mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingFishQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingFishQuestion")] + public class ForecastingFishQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Added: mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/ForecastingPeopleQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.ForecastingPeopleQuestion")] + public class ForecastingPeopleQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Deleted: mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/actionscript/InstructionPageLoader.as 2009-06-17 23:29:38 UTC (rev 165) @@ -1,10 +0,0 @@ -package actionscript -{ - public class InstructionPageLoader - { - public function InstructionPageLoader() - { - } - - } -} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-17 23:29:38 UTC (rev 165) @@ -1,16 +1,17 @@ // ActionScript file package actionscript { - import customComponents.questions.TextQuestionC; - import customComponents.questions.ForecastingQuestionC; import customComponents.questions.CategoricalQuestionC; + import customComponents.questions.ForecastingFishQuestionC; + import customComponents.questions.ForecastingPeopleQuestionC; import customComponents.questions.PsychometricQuestionC; + import customComponents.questions.StrategyDesignQuestionC; + import customComponents.questions.TextQuestionC; import flash.display.DisplayObject; import mx.collections.ArrayCollection; import mx.containers.VBox; - import mx.controls.ComboBox; import mx.controls.Label; import mx.controls.Text; @@ -69,14 +70,30 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is ForecastingQuestion) + if(tempQuestion is StrategyDesignQuestion) { - var fq:ForecastingQuestionC = new ForecastingQuestionC(); - fq.loadFromQuestion(ForecastingQuestion(tempQuestion)); - fq.id = "q"+question; + var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); + sdq.loadFromQuestion(StrategyDesignQuestion(tempQuestion)); + sdq.id = "q"+question; - tempBox.addChild(fq); + tempBox.addChild(sdq); } + else if(tempQuestion is ForecastingPeopleQuestion) + { + var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); + fpq.loadFromQuestion(ForecastingPeopleQuestion(tempQuestion)); + fpq.id = "q"+question; + + tempBox.addChild(fpq); + } + else if(tempQuestion is ForecastingFishQuestion) + { + var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); + ffq.loadFromQuestion(ForecastingFishQuestion(tempQuestion)); + ffq.id = "q"+question; + + tempBox.addChild(ffq); + } else if(tempQuestion is CategoricalQuestion) { var cq:CategoricalQuestionC = new CategoricalQuestionC(); Added: mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as (rev 0) +++ mentalmodels/trunk/flex/src/actionscript/StrategyDesignQuestion.as 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,11 @@ +package actionscript +{ + import mx.collections.ArrayCollection; + + [Bindable] + [RemoteClass(alias="edu.asu.commons.mme.entity.StrategyDesignQuestion")] + public class StrategyDesignQuestion extends Question + { + public var numDays:int; + } +} \ No newline at end of file Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -55,7 +55,7 @@ <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> <quest:PsychometricQuestionC id="psychometricQuestion" description="Overall, how much do you like your group?" labels="{psychometricLabels}" maxValue="3"/> - <quest:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" + <quest:CategoricalQuestionC id="categoricalQuestion" description="What goals did you follow when designing your strategy?" topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> <quest:TextQuestionC id="textQuestion" description="Describe in your own words what the rule, agreement, or other coordination attempt states." defaultText="Enter your response here..." txtHeight="48"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/CategoricalQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,20 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:as="actionscript.*"> - <mx:String id="title"></mx:String> <mx:String id="description"></mx:String> <mx:VBox id="headers"> <mx:Label/> - <mx:Label htmlText="{htmlBold(title)}"/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:HBox id="content"> <mx:ComboBox id="comboTopic" Added: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingFishQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + + <components:ForecastComponent id="fishEntry" style="1" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false" + updaterObject="{this}" updater="{recalculate}"/> + <components:ForecastComponent id="peopleDisplay" style="0" isEntry="false" + numBays="{numBays}" numColumns="15" initialize="false"/> + <components:ForecastComponent id="calculated" style="2" isEntry="false" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:Script> + <![CDATA[ + import mx.controls.Alert; + import actionscript.ForecastingFishQuestion; + import mx.collections.ArrayCollection; + import customComponents.questions.components.ForecastComponent; + + public var loadFish:ArrayCollection = null; + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 6; + + public function init():void + { + fishEntry.initialize(); fishEntry.init(); + peopleDisplay.initialize(); peopleDisplay.init(); + calculated.initialize(); calculated.init(); + + if(loadFish != null) + { + fishEntry.load(loadFish); + } + if(loadPeople != null) + { + peopleDisplay.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return fishEntry.save(); + } + public function load(newFishEntry:ArrayCollection,newPeopleDisplay:ArrayCollection):void + { + loadFish = newFishEntry; + loadPeople = newPeopleDisplay; + init(); + } + public function loadFromQuestion(question:ForecastingFishQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + public function recalculate():void + { + var currLoc:int = 0; + + var fishCols:int = fishEntry.dataGrid.columns.length; + var pplCols:int = peopleDisplay.dataGrid.columns.length; + var calcCols:int = calculated.dataGrid.columns.length; + + for(var column:int = 0; column < fishCols && column < pplCols && column < calcCols; column++) + { + calculated.setItem(0,column,currLoc); + calculated.setItem(1,column,0); + calculated.setItem(2,column,0); + + for(var bay:int = 0; bay < numBays; bay++) + { + calculated.setItem(3+bay,column,Number(fishEntry.getItem(bay,column)) * 0.9); + } + } + calculated.redraw(); + } + + ]]> + </mx:Script> + +</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingPeopleQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="customComponents.questions.components.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> + + <components:ForecastComponent id="peopleEntry" style="0" isEntry="true" + numBays="{numBays}" numColumns="{numColumns}" initialize="false"/> + + <mx:Script> + <![CDATA[ + import actionscript.ForecastingPeopleQuestion; + import mx.collections.ArrayCollection; + import customComponents.questions.components.ForecastComponent; + + public var loadPeople:ArrayCollection = null; + + [Bindable] public var numBays:int = 3; + [Bindable] public var numColumns:int = 15; + + public function init():void + { + peopleEntry.initialize(); peopleEntry.init(); + + if(loadPeople != null) + { + peopleEntry.load(loadPeople); + } + } + + public function save():ArrayCollection + { + return peopleEntry.save(); + } + public function load(newPeopleDisplay:ArrayCollection):void + { + loadPeople = newPeopleDisplay; + init(); + } + public function loadFromQuestion(question:ForecastingPeopleQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/ForecastingQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:HBox id="buttons"> <mx:Button id="btnForward" label="Forecast Fish" click="forward()"/> Modified: mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/PsychometricQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:Canvas id="content" minHeight="30" maxHeight="90"> <!-- Used for bipolar psychometric scales --> Modified: mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/StrategyDesignQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:qComp="customComponents.questions.components.*"> - <mx:Label text="Strategy Design" fontSize="24"/> - <mx:Text text="Please create a plan for the month. You will visit each of the locations listed in the left column in order. You will then do the same using the right column, but repeat until the 30 days are completed. If you do not manage to mine enough fish after one repetition, you may wait a few days until fishing again." - width="600"/> - <mx:Label/> + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <mx:Label/> + <mx:Text htmlText="{description}"/> + </mx:VBox> <mx:HBox> <mx:VBox> @@ -32,6 +33,7 @@ <mx:Script> <![CDATA[ + import actionscript.StrategyDesignQuestion; import mx.collections.ArrayCollection; public function getNotRepeated():ArrayCollection @@ -63,6 +65,14 @@ suspendDays.value = loadArray.getItemAt(3) as Number; } + public function loadFromQuestion(question:StrategyDesignQuestion):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/TextQuestionC.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -6,13 +6,6 @@ <mx:Label/> <mx:Text htmlText="{description}"/> </mx:VBox> - <mx:Script> <![CDATA[ - public function htmlBold(str:String):String - { - if(str==null)return null; - return "<font size=\"12px\">" + str + "</font>"; - } - ]]> </mx:Script> <mx:Number id="txtWidth">200</mx:Number> <mx:Number id="txtHeight">24</mx:Number> Modified: mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-06-17 19:19:34 UTC (rev 164) +++ mentalmodels/trunk/flex/src/customComponents/questions/components/ForecastComponent.mxml 2009-06-17 23:29:38 UTC (rev 165) @@ -17,9 +17,11 @@ [Bindable] public var dataGrid:DataGrid; [Bindable] public var dataProvider:ArrayCollection; [Bindable] public var errorMessage:String = ""; + [Bindable] public var updaterObject:Object = null; + [Bindable] public var updater:Function = new Function(); // Game Data - [Bindable] public var style:int = 0; // 0:PeopleEntry, 1:PeopleViewing, 2:FishEntry, 3:CalculatedViewing + [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated [Bindable] public var numBays:int = 3; [Bindable] public var numColumns:int = -1; [Bindable] public var numFields:int = 15; @@ -27,6 +29,7 @@ [Bindable] public var maxValue:int = 5; [Bindable] public var groupSize:int = 4; [Bindable] public var finished:Boolean = false; + [Bindable] public var isEntry:Boolean = false; // for lining up grids [Bindable] public var minimumWidth:int = 160; @@ -37,6 +40,10 @@ public function init():void { + labels.removeAllChildren(); + removeAllChildren(); + addChild(labels); + createGrid(); fillGridColumns(); fillGridFields(); @@ -73,10 +80,12 @@ public function changed(event:Object=null):void { - if((style == 0) || (style == 2)) // 0:PeopleEntry, 2:FishEntry + if(isEntry && style != 2) // NOT 2:Calculated { errorCheck(); } + try{updater.call(updaterObject);} + catch(err:Error){/* Alert.show(err.message+"\n"+err.getStackTrace()); */} redraw(); } @@ -135,7 +144,7 @@ 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 + newDataGridColumn.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish newDataGridColumn.draggable = false; newDataGridColumn.sortable = false; newDataGridColumn.resizable = false; @@ -145,7 +154,7 @@ } dataGrid.columns = columnArray; - dataGrid.editable = ((style == 0) || (style == 2)); // 0:PeopleEntry, 2:FishEntry + dataGrid.editable = (isEntry && ((style == 0) || (style == 1))); // 0:People, 1:Fish } private function fillGridFields():void @@ -153,9 +162,9 @@ dataProvider = new ArrayCollection(); var bayNumber:int = 0; - if(style==0 || style==1) // 0:PeopleEntry, 1:PeopleViewing + if(style==0) // 0:People { - if(style==0) + if(isEntry) { addLabel(" <b>Predict</b>:",true); } @@ -173,9 +182,16 @@ addField(); } } - else if(style==2) + else if(style==1) { - addLabel(" <b>Predict:</b>",true); + if(isEntry) + { + addLabel(" <b>Predict</b>:",true); + } + else + { + addLabel(" <b>You Predicted</b>:",true); + } for(bayNumber=0; bayNumber<numBays; bayNumber++) { @@ -183,7 +199,7 @@ addField(); } } - else if(style==3) + else if(style==2) { addLabel(" <b>We calculate that:</b>",true); @@ -207,14 +223,13 @@ { switch(style) { - case(0): - case(1): // 0:PeopleEntry, 1:PeopleViewing + case(0): // 0:People dataGrid.height = (23)*(numBays+2)-1; break; - case(2): // 2:FishEntry + case(1): // 2:Fish dataGrid.height = (23)*(numBays+1); break; - case(3): // 3:CalculatedViewing + case(2): // 3:Calculated dataGrid.height = (23)*(numBays+4)-3; break; } @@ -243,13 +258,13 @@ error = true; markError(field,column); } - else if(style == 0) // 0:PeopleEntry + else if(style == 0) // 0:People { colSum += Number(value); } } - if(!error && style == 0 && colSum != groupSize-1) // 0:PeopleEntry + if(!error && style == 0 && colSum != groupSize-1) // 0:People { errorMessage = "Sum of all columns must be exactly "+(groupSize-1)+"."; error = true; @@ -273,7 +288,7 @@ } public function markError(field:Number, column:Number):void { - if(style != 0 && style != 2) return; // 0:PeopleEntry, 2:FishEntry + if(! (isEntry && (style == 0 || style == 1)) ) return; // 0:People, 1:Fish DataGridColumn(dataGrid.columns[column]).setStyle("backgroundColor", "#ee82ee"); dataGrid.selectedIndex = field; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |