[virtualcommons-svn] SF.net SVN: virtualcommons:[439] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2010-01-15 23:40:50
|
Revision: 439 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=439&view=rev Author: kjonas Date: 2010-01-15 23:40:43 +0000 (Fri, 15 Jan 2010) Log Message: ----------- added list of locations to the DataModel.as file and updated references to load/save from here. SocioDemographicPage.mxml pre-fills data fields with testing information StrategyDesignQuestionC.mxml has been tested to at least *look* properly. may not function (save to server) Modified Paths: -------------- mentalmodels/trunk/flex/src/actionscript/DataModel.as mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml Modified: mentalmodels/trunk/flex/src/actionscript/DataModel.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/DataModel.as 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/actionscript/DataModel.as 2010-01-15 23:40:43 UTC (rev 439) @@ -1,12 +1,22 @@ package actionscript { + import mx.collections.ArrayCollection; + public class DataModel { private static const INSTANCE:DataModel = new DataModel(); public var studentObject:actionscript.Student = null; public var gameObject:actionscript.Game = null; + public var locations:ArrayCollection = null; + private function newLocation(maxCapacity:Number,growth:Number):Location + { + var newLoc:Location = new Location(); + newLoc.growthRate = growth; + return newLoc; + } + public function DataModel():void { if (INSTANCE != null) Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2010-01-15 23:40:43 UTC (rev 439) @@ -29,27 +29,17 @@ public var currentPageNumber:int; public var highestPageReached:int; - public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - public var currBlock:Block; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - // requires a block, and a list of locations. // the "minimumPagesRead" variable will not let the student finish the block until that // many pages have been viewed. - public function PageDisplay(newBlock:Block, minimumPagesRead:int, locations:ArrayCollection) + public function PageDisplay(newBlock:Block, minimumPagesRead:int) { currBlock = newBlock; minPagesRead = minimumPagesRead; currentPageNumber = 0; highestPageReached = currentPageNumber; - this.locations = locations; // generates the objects that will be displayed on each "page" in the block loadPages(); @@ -116,9 +106,8 @@ else if(tempQuestion.type.toLowerCase() == "strategydesign") { var sdq:StrategyDesignQuestionC = new StrategyDesignQuestionC(); - sdq.locations = locations; - sdq.setRound(gameObject.currentRound); sdq.loadFromQuestion(Question(tempQuestion)); + sdq.setRound(DataModel.instance.gameObject.currentRound); sdq.id = "q"+question; tempBox.addChild(sdq); @@ -126,7 +115,6 @@ else if(tempQuestion.type.toLowerCase() == "daybydaydecisions") { var ddq:DayByDayDecisionsQuestionC = new DayByDayDecisionsQuestionC(); - ddq.locations = locations; ddq.loadFromQuestion(Question(tempQuestion)); ddq.id = "q"+question; @@ -135,7 +123,6 @@ else if(tempQuestion.type.toLowerCase() == "forecastingfishermen") { var fpq:ForecastingPeopleQuestionC = new ForecastingPeopleQuestionC(); - fpq.locations = locations; fpq.loadFromQuestion(tempQuestion); fpq.id = "q"+question; @@ -144,7 +131,6 @@ else if(tempQuestion.type.toLowerCase() == "forecastingfish") { var ffq:ForecastingFishQuestionC = new ForecastingFishQuestionC(); - ffq.locations = locations; ffq.loadFromQuestion(tempQuestion); ffq.id = "q"+question; Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -19,8 +19,7 @@ <!-- This is a temporary state that jumpstarts the "instructions" state for the first time --> <mx:State name="instructionsLoad"> <mx:AddChild relativeTo="{content}"> - <comp:InstructionPage id="instructions" initialize="gotoInstructions()" x="0" y="0" - preinitialize="instructions.setLocations(locations)"/> + <comp:InstructionPage id="instructions" initialize="gotoInstructions()" x="0" y="0"/> </mx:AddChild> </mx:State> @@ -118,7 +117,6 @@ public var gameObject:actionscript.Game = null; public var currentBlock:Block = null; public var currentBlockNumber:int = 0; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var instructionsLoaded:Boolean = false; [Bindable] public var studentObject:actionscript.Student; [Bindable] public var roundObject:actionscript.Round; @@ -144,7 +142,7 @@ // Responds to ArrayCollection by assuming it is of Student objects // This code assigns group and student numbers based on the object whose id // matches studentObject - if(event.message.body is actionscript.Game) + if(event.message.body as actionscript.Game != null) { gameObject = event.message.body as actionscript.Game; DataModel.instance.gameObject = gameObject; @@ -154,12 +152,12 @@ instructions.setGameObject(this.gameObject); } } - else if(event.message.body is actionscript.Block) + else if(event.message.body as actionscript.Block != null) { Alert.show("Server sent Block, not Game.",""); setBlock(event.message.body as actionscript.Block); } - else if(event.message.body is ArrayCollection) + else if(event.message.body as ArrayCollection != null) { var students:ArrayCollection = new ArrayCollection(); students = ArrayCollection(event.message.body); @@ -182,7 +180,7 @@ } } } -// Alert.show("Current Student Information is: " + "\n"+SingletonStudent.instance.studentObject.id +"\n"+SingletonStudent.instance.studentObject.gameCode+"\n"+SingletonStudent.instance.studentObject.studentNo); +// Alert.show("Current Student Information is: " + "\n"+DataModel.instance.studentObject.id +"\n"+DataModel.instance.studentObject.gameCode+"\n"+DataModel.instance.studentObject.studentNo); } } @@ -221,15 +219,6 @@ Alert.show("Block received in Instructions (load) state.","Unexpected Block"); } } - - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - //newLoc.maxCapacity = maxCapacity; - //newLoc.initialPopulation = maxCapacity / 2.0; - newLoc.growthRate = growth; - return newLoc; - } public function init():void { @@ -302,7 +291,7 @@ else if(curr.getChildAt(j) is ForecastingPeopleQuestionC) { var forecast1:ForecastingPeopleQuestionC = (curr.getChildAt(j) as ForecastingPeopleQuestionC); - for(row=0; row<locations.length; row++) + for(row=0; row<DataModel.instance.locations.length; row++) { studentResponse = new StudentResponse(); studentResponse.student = studentObject; @@ -325,7 +314,7 @@ else if(curr.getChildAt(j) is ForecastingFishQuestionC) { var forecast2:ForecastingFishQuestionC = (curr.getChildAt(j) as ForecastingFishQuestionC); - for(row=0; row<locations.length-1; row++) + for(row=0; row<DataModel.instance.locations.length-1; row++) { studentResponse = new StudentResponse(); studentResponse.student = studentObject; @@ -357,7 +346,7 @@ for(var k:int=0;k<tempDBObjects.length;k++) { - (tempDBObjects.getItemAt(k) as StudentStrategy).student = studentObject; + (tempDBObjects.getItemAt(k) as StudentStrategy).student = DataModel.instance.studentObject; (tempDBObjects.getItemAt(k) as StudentStrategy).round = roundObject; } @@ -444,11 +433,7 @@ { if(event.result is ArrayCollection) { - locations = event.result as ArrayCollection; - if(instructions != null) - { - instructions.setLocations(locations); - } + DataModel.instance.locations = event.result as ArrayCollection; } } private function strategyResultHandler(event:ResultEvent):void Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -25,21 +25,12 @@ [Bindable] public var numPages:int = 1; [Bindable] public var currPage:int = 0; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - // saved for use in information windows, etc public var savedForecastPeople:ArrayCollection = null; public var savedForecastFish:ArrayCollection = null; public var savedStrategyDesign:ArrayCollection = null; public var savedDayByDayDecisions:ArrayCollection = null; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - // makes sure the pageDisplay has been created // then gives it gameObject public function setGameObject(newGameObject:actionscript.Game):void @@ -87,18 +78,18 @@ if(block != null && block.questionGroups != null) { minPagesRead = block.questionGroups.length - pageDisplay = new PageDisplay(block, minPagesRead,locations); + pageDisplay = new PageDisplay(block, minPagesRead); } if(pageDisplay == null) { debug2.text += "pageDisplay is null\n"; - pageDisplay = new PageDisplay(makeBlock(),0,locations); + pageDisplay = new PageDisplay(makeBlock(),0); } }catch(errObject:Error){ // worst case scenario... still needs to have a pagedisplay debug2.text += "pageDisplay creation failure\n" + errObject.name +"\n"+ errObject.message +"\n"+ errObject.getStackTrace() +"\n"; - pageDisplay = new PageDisplay(makeBlock(),0,locations); + pageDisplay = new PageDisplay(makeBlock(),0); // Alert.show(debug2.text); } setGameObject(this.gameObject); @@ -251,15 +242,6 @@ return block; } - public function setLocations(newLocations:ArrayCollection):void - { - locations = newLocations; - if(pageDisplay != null) - { - pageDisplay.locations = newLocations; - } - } - ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/SocioDemographicPage.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -1,10 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center" + creationComplete="test_init()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; + public function test_init():void + { + radioMale.selected = true; + txtYear.text = "2010"; + txtMajor.text = "CSE"; + txtGameCode.text = "test1"; + } + public function getGender():String { if(radioMale.selected) { return "M"; } Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/DayByDayDecisionsQuestionC.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -22,6 +22,7 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.Location; import mx.controls.Alert; import mx.collections.ArrayCollection; @@ -30,18 +31,10 @@ import actionscript.questions.*; import custom.questions.dayByDayDecisions.OneDay; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); [Bindable] public var deciding:int = 0; [Bindable] public var cumTotal:Number = 0; [Bindable] public var dollarPerLb:Number = 3.99; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { buttons.removeAllChildren(); @@ -64,7 +57,7 @@ txtTemp.text = "Harbor"; labels.addChild(txtTemp); - for(var i:int = 1; i < locations.length; i++) + for(var i:int = 1; i < DataModel.instance.locations.length; i++) { btnTemp = new Button(); btnTemp.label = "Bay" + (i); @@ -125,7 +118,6 @@ } var newDay:OneDay = new OneDay(); - newDay.locations = locations; newDay.initialize(); newDay.day = dayByDayContent.numChildren + 1; newDay.dollarPerLb = dollarPerLb; @@ -149,7 +141,6 @@ var day:OneDay = dayByDayContent.getChildAt(i) as OneDay; var newDay:OneDay = new OneDay(); - newDay.locations = locations; newDay.initialize(); newDay.day = day.day; newDay.dollarPerLb = day.day; Modified: mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/dayByDayDecisions/OneDay.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -3,12 +3,12 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.Location; import mx.controls.Text; import mx.controls.Label; import mx.collections.ArrayCollection; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); [Bindable] public var decisions:ArrayCollection; public var previousTotal:Number = 0; @@ -16,20 +16,13 @@ public var day:int = 1; public var dollarPerLb:Number = 3.99; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { if(decisions == null) { drawNull(); } - else if(decisions.length < locations.length+1) + else if(decisions.length < DataModel.instance.locations.length+1) { drawPartial(); } @@ -55,7 +48,7 @@ public function drawPartial():void { var temp:OneDecision; - for(var i:int = decisions.length; i < locations.length; i++) + for(var i:int = decisions.length; i < DataModel.instance.locations.length; i++) { temp = new OneDecision(); temp.active = false; @@ -78,7 +71,7 @@ dayText.minWidth = 50; addChild(dayText); - for(var i:int = 0; i < locations.length && i < decisions.length; i++) + for(var i:int = 0; i < DataModel.instance.locations.length && i < decisions.length; i++) { var temp:OneDecision = (decisions.getItemAt(i) as OneDecision); presentTotal += temp.lbsFished; @@ -108,7 +101,7 @@ } else { - for(var i:int = 0; i < locationChosen && i < locations.length; i++) + for(var i:int = 0; i < locationChosen && i < DataModel.instance.locations.length; i++) { var tempInactive:OneDecision = new OneDecision(); tempInactive.active = false; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastComponent.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -5,6 +5,7 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.Location; import mx.controls.Alert; import mx.events.FlexEvent; @@ -26,7 +27,7 @@ // Game Data [Bindable] public var style:int = 0; // 0:People, 1:Fish, 2:Calculated // [Bindable] public var numBays:int = 3; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + [Bindable] public var locations:ArrayCollection = DataModel.instance.locations; [Bindable] public var numColumns:int = -1; [Bindable] public var numFields:int = 15; [Bindable] public var minValue:int = 0; @@ -38,13 +39,6 @@ // for lining up grids [Bindable] public var minimumWidth:int = 160; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - // // public accessible functions // Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingFishQuestionC.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -27,6 +27,7 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.questions.Question; import actionscript.Location; import mx.controls.Alert; @@ -36,17 +37,10 @@ public var loadFish:ArrayCollection = null; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + [Bindable] public var locations:ArrayCollection = DataModel.instance.locations; [Bindable] public var numColumns:int = 6; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { if(fishEntry == null || peopleDisplay == null || calculated == null) return; Modified: mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/forecasting/ForecastingPeopleQuestionC.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -24,6 +24,7 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.questions.Question; import actionscript.Location; import actionscript.questions.ForecastingPeople; @@ -31,17 +32,10 @@ import custom.questions.forecasting.ForecastComponent; public var loadPeople:ArrayCollection = null; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + [Bindable] public var locations:ArrayCollection = DataModel.instance.locations; [Bindable] public var numColumns:int = 15; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { if(peopleEntry == null) return; Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/Planner.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -12,16 +12,8 @@ public var valueRequired:Boolean = false; public var hasBeenChanged:Boolean = false; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); public var round:Round = null; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { if(valueRequired && grid.numChildren == 0) @@ -40,7 +32,6 @@ { var newRow:PlannerRow = new PlannerRow(); newRow.valueRequired = this.valueRequired; - newRow.locations = locations; newRow.initialize(); newRow.init(); var newNumber:Label = new Label(); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -3,18 +3,12 @@ <mx:Script> <![CDATA[ + import actionscript.DataModel; import actionscript.Location; public var valueRequired:Boolean = false; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); + [Bindable] public var locations:ArrayCollection = DataModel.instance.locations; - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { locs.removeAll(); Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2010-01-15 23:36:34 UTC (rev 438) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/StrategyDesignQuestionC.mxml 2010-01-15 23:40:43 UTC (rev 439) @@ -26,15 +26,6 @@ import actionscript.questions.Question; import mx.collections.ArrayCollection; - [Bindable] public var locations:ArrayCollection = new ArrayCollection([newLocation(0, 0)]); - - private function newLocation(maxCapacity:Number,growth:Number):Location - { - var newLoc:Location = new Location(); - newLoc.growthRate = growth; - return newLoc; - } - public function init():void { } @@ -82,7 +73,6 @@ initialize(); init(); - repeated.locations = locations; repeated.init(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |