[virtualcommons-svn] SF.net SVN: virtualcommons:[186] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-07-16 21:00:49
|
Revision: 186 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=186&view=rev Author: kjonas Date: 2009-07-16 21:00:46 +0000 (Thu, 16 Jul 2009) Log Message: ----------- Deleted old file. Added HelpImage.png and corresponding information window. Added timers to the main page, can be set to a percentage. (Currently setting to increasing percentages with a timer) Altered the accept() function of InstructionPage.mxml to return an int representing whether the block or module was completed, or neither. Changed functions related to accept(), allowing the program to tell the server what block they are on, as opposed to only on modules. Modified Paths: -------------- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml mentalmodels/trunk/flex/src/custom/InstructionPage.mxml mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/HelpImage.png Removed Paths: ------------- mentalmodels/trunk/flex/src/custom/TimeLabel.mxml Modified: mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml =================================================================== --- mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/FisheryExperimentShell.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -1,50 +1,77 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:custom="custom.*" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #B0B0FF]" - layout="horizontal" horizontalGap="30" - width="100%" height="100%" xmlns:custom="custom.*" + width="100%" height="100%" layout="vertical" horizontalAlign="center" initialize="init()"> - <!--<mx:Button id="btnTemp" label="Update" click="updateObjectA.updateLearned(new ArrayCollection([new ArrayCollection(['test']),new ArrayCollection(['test']),new ArrayCollection(['test'])]))"/>--> + <mx:Script><![CDATA[ + public var progressTimer:Timer; + [Bindable] public var progressBarWidth:Number = 600; + public function progressBarInit():void + { + progressTimer = new Timer(100, 100); // 21600 * 1000 = 6hrs + progressTimer.addEventListener(TimerEvent.TIMER, timerTick); + progressTimer.start(); + } + public function timerTick(event:TimerEvent):void + { + tick(progressTimer.currentCount/2/progressTimer.repeatCount, progressTimer.currentCount/progressTimer.repeatCount); + } + private function tick(percentModule:Number,percentBlock:Number):void + { + progressBarModule.width = progressBarWidth*percentModule; + progressBarBlock.width = progressBarWidth*percentBlock; + } + ]]></mx:Script> - <mx:VBox id="vbxInfo"> - <mx:TitleWindow id="InformationWindowA" width="400" height="200" title="Information Window A" - clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - </mx:TitleWindow> - <mx:HBox id="hbxPickerA"> - <mx:ComboBox id="cbxPickerA" maxWidth="225" change="cbxChanged()"/> - <mx:Button id="btnPickerA" label="Pop Up" click="popupInformationWindow(1)"/> - </mx:HBox> + <mx:HBox horizontalGap="30" y="60"> + <mx:VBox id="vbxInfo"> + <mx:TitleWindow id="InformationWindowA" width="400" height="220" title="Information Window A" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + </mx:TitleWindow> + <mx:HBox id="hbxPickerA"> + <mx:ComboBox id="cbxPickerA" maxWidth="225" change="cbxChanged()"/> + <mx:Button id="btnPickerA" label="Pop Up" click="popupInformationWindow(1)"/> + </mx:HBox> + + <mx:TitleWindow id="InformationWindowB" width="400" height="220" title="Information Window B" + clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> + </mx:TitleWindow> + <mx:HBox id="hbxPickerB"> + <mx:ComboBox id="cbxPickerB" maxWidth="225" change="cbxChanged()"/> + <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> + </mx:HBox> + + <mx:Button id="btnResetPopups" label="Reset Popups" click="{closedFunction(1);closedFunction(2)}"/> + </mx:VBox> - <mx:TitleWindow id="InformationWindowB" width="400" height="200" title="Information Window B" - clipContent="true" horizontalScrollPolicy="on" verticalScrollPolicy="on"> - </mx:TitleWindow> - <mx:HBox id="hbxPickerB"> - <mx:ComboBox id="cbxPickerB" maxWidth="225" change="cbxChanged()"/> - <mx:Button id="btnPickerB" label="{btnPickerA.label}" click="popupInformationWindow(2)"/> - </mx:HBox> - - <mx:Button id="btnResetPopups" label="Reset Popups" click="{closedFunction(1);closedFunction(2)}"/> - </mx:VBox> + <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> + <mx:VBox id="progressBars" x="0" y="0" verticalGap="0" initialize="progressBarInit()"> + <mx:HBox> + <mx:Label text="Time for Module:" width="130" textAlign="right"/> + <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> + <mx:HBox id="progressBarModule" height="10" backgroundColor="#00FF00"/> + </mx:HBox> + </mx:HBox> + <mx:HBox> + <mx:Label text="Time for Block:" width="130" textAlign="right"/> + <mx:HBox width="{progressBarWidth+2}" borderStyle="solid"> + <mx:HBox id="progressBarBlock" height="10" backgroundColor="#00FF00"/> + </mx:HBox> + </mx:HBox> + </mx:VBox> + <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> + </mx:VBox> + </mx:HBox> - <mx:VBox id="vbxContent" horizontalAlign="center" verticalAlign="middle"> - <custom:FisheryExperimentCore id="fisheryContent" blockLoader="loadBlock"/> - </mx:VBox> - <mx:Script> <![CDATA[ import mx.controls.Alert; - import mx.controls.Spacer; - import mx.controls.Image; - import mx.controls.TextArea; - import mx.controls.Text; import mx.controls.Label; - import mx.containers.Canvas; import actionscript.Block; import actionscript.Module; import actionscript.InformationWindowCreator; import mx.collections.ArrayCollection; - import mx.skins.halo.TitleBackground; import custom.InformationWindowPopup; import mx.managers.PopUpManager; @@ -168,13 +195,18 @@ public function selectCurrentWindows(selectedWindows:ArrayCollection):void { + var mustHaveWindows:ArrayCollection = new ArrayCollection([0,2,3]); + + closedFunction(1); + closedFunction(2); + currInfoWindowsA = new ArrayCollection(); currInfoWindowsB = new ArrayCollection(); currInfoWindowsDescriptions = new ArrayCollection(); for(var i:int = 0; i < allInfoWindowsA.length; i++) { - if(selectedWindows.contains(i)) + if(selectedWindows.contains(i) || mustHaveWindows.contains(i)) { currInfoWindowsA.addItem(allInfoWindowsA.getItemAt(i)); currInfoWindowsB.addItem(allInfoWindowsB.getItemAt(i)); Added: mentalmodels/trunk/flex/src/HelpImage.png =================================================================== (Binary files differ) Property changes on: mentalmodels/trunk/flex/src/HelpImage.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/actionscript/InformationWindowCreator.as 2009-07-16 21:00:46 UTC (rev 186) @@ -94,6 +94,24 @@ tempWindow = new ArrayCollection(); temp = new Label(); + (temp as Label).text = "How to Navigate the Program (Help)"; + (temp as Label).setStyle("fontSize",14); + (temp as Label).setStyle("fontWeight","bold"); + tempWindow.addItem(temp); + + [Embed(source="HelpImage.png")] var helpImg:Class; + temp = new Image(); + (temp as Image).source = helpImg; + tempWindow.addItem(temp); + + allInfoWindows.addItem(tempWindow); + allInfoWindowsDescriptions.addItem("Help"); + + //// + // Window 1 + tempWindow = new ArrayCollection(); + + temp = new Label(); (temp as Label).text = "This is an Information Window"; (temp as Label).setStyle("fontSize",14); (temp as Label).setStyle("fontWeight","bold"); @@ -108,7 +126,7 @@ allInfoWindowsDescriptions.addItem("Dummy Window"); //// - // Window 1 + // Window 2 tempWindow = new ArrayCollection(); temp = new Label(); @@ -117,9 +135,9 @@ (temp as Label).setStyle("fontWeight","bold"); tempWindow.addItem(temp); - [Embed(source="LakeImage.png")] var img:Class; + [Embed(source="LakeImage.png")] var lakeImg:Class; temp = new Image(); - (temp as Image).source = img; + (temp as Image).source = lakeImg; (temp as Image).maxWidth = 600; (temp as Image).maxHeight = 600; tempWindow.addItem(temp); @@ -128,7 +146,7 @@ allInfoWindowsDescriptions.addItem("Model of the Fishing Ground"); //// - // Window 2 + // Window 3 tempWindow = new ArrayCollection(); temp = new Label(); @@ -240,7 +258,7 @@ allInfoWindowsDescriptions.addItem("Important Formulas"); //// - // Window 3 + // Window 4 tempWindow = new ArrayCollection(); temp = new Label(); @@ -307,7 +325,7 @@ allInfoWindowsDescriptions.addItem("Help for Strategy Design"); //// - // Window 4 + // Window 5 tempWindow = new ArrayCollection(); temp = new Label(); @@ -326,7 +344,7 @@ allInfoWindowsDescriptions.addItem("Your Strategy"); //// - // Window 5 + // Window 6 tempWindow = new ArrayCollection(); temp = new Label(); @@ -368,7 +386,7 @@ allInfoWindowsDescriptions.addItem("Your Goals"); //// - // Window 6 + // Window 7 tempWindow = new ArrayCollection(); temp = new Label(); @@ -386,7 +404,7 @@ allInfoWindowsDescriptions.addItem("Your Forecast"); //// - // Window 7 + // Window 8 tempWindow = new ArrayCollection(); temp = new Label(); @@ -404,7 +422,7 @@ allInfoWindowsDescriptions.addItem("Day-by-Day Results"); //// - // Window 8 + // Window 9 tempWindow = new ArrayCollection(); temp = new Label(); @@ -422,7 +440,7 @@ allInfoWindowsDescriptions.addItem("Strategy Results"); //// - // Window 9 + // Window 10 tempWindow = new ArrayCollection(); temp = new Label(); @@ -459,7 +477,7 @@ allInfoWindowsDescriptions.addItem("Notes - Yourself"); //// - // Window 10 + // Window 11 tempWindow = new ArrayCollection(); temp = new Label(); @@ -525,10 +543,10 @@ content.addItem(allInfoWindowsDescriptions); content.addItem(updateObject); -for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) -{ - allInfoWindowsDescriptions.setItemAt(endLoop +" "+ (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); -} +//for(var endLoop:int; endLoop < allInfoWindowsDescriptions.length; endLoop++) +//{ +// allInfoWindowsDescriptions.setItemAt(endLoop +" "+ (allInfoWindowsDescriptions.getItemAt(endLoop) as String), endLoop); +//} return content; //InformationWindowA.addChild( allInfoWindows.getItemAt(0) as DisplayObject ); Modified: mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/FisheryExperimentCore.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -49,9 +49,11 @@ <mx:Canvas id="content" x="0" y="0" width="720" height="475"/> <mx:Canvas id="expiredContent" x="-1" y="-1" width="1" height="1" visible="false"/> - <mx:Button id="btnBack" label="« Back" click="back()" left="0" bottom="0" enabled="false"/> - <mx:Button id="btnAccept" label="Accept" click="accept()" left="{(width-btnAccept.width)/2}" bottom="0"/> - <mx:Button id="btnForward" label="Forward »" click="forward()" right="0" bottom="0" enabled="false"/> + <mx:HBox id="buttonBar" left="{(width-buttonBar.width)/2}" bottom="0" horizontalGap="150"> + <mx:Button id="btnBack" label="« Back" click="back()" enabled="false"/> + <mx:Button id="btnAccept" label="Accept" click="accept()" /> + <mx:Button id="btnForward" label="Forward »" click="forward()" enabled="false"/> + </mx:HBox> <mx:RemoteObject id="ss" destination="studentService" fault="faultHandler(event)" result="resultHandler(event)"/> <mx:Producer id="producer" destination="DataPush" acknowledge="ack(event)"/> @@ -128,9 +130,15 @@ { } + private function reportBlockFinished():void + { + sendBlockQuestions(); + + // send something to server to indicate that someone finished a block + } private function getNextModule():void { - sendBlockQuestions(); + reportBlockFinished(); currModule = null; currModuleNumber++; @@ -260,15 +268,13 @@ obj.visible = false; expiredContent.addChild(obj); - currentState = "wait"; - getNextModule(); - - var info:SocioDemographicPage = SocioDemographicPage(obj); Id=ss.createStudent(info.getYear(), info.getSemester(), info.getGender(),info.getMajor()); + currentState = "wait"; btnBack.enabled = btnForward.enabled = true; + getNextModule(); returnValue = true; } } @@ -276,27 +282,31 @@ { try { - if( (InstructionPage)(obj).accept() ) + var instructionPageAcceptValue:int = (InstructionPage)(obj).accept(); + if( instructionPageAcceptValue == 2 ) { obj.visible = false; expiredContent.addChild(obj); currentState = "wait"; + //consumer.subscribe(); + getNextModule(); - //consumer.subscribe(); returnValue = true; } - else + else if( instructionPageAcceptValue == 1 ) { - var newCurrBlock:Block = (InstructionPage)(obj).block; - if(newCurrBlock != currBlock) - { - currBlock = newCurrBlock; - currBlockNumber++; - blockLoader.call(); - } + currBlock = (InstructionPage)(obj).block; + currBlockNumber++; + blockLoader.call(); + + reportBlockFinished(); + returnValue = true; } } - catch(err:Error){} + catch(err:Error) + { + returnValue = false; + } } btnBack.enabled = btnForward.enabled = (currentState == "instructions"); Modified: mentalmodels/trunk/flex/src/custom/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/InstructionPage.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -141,7 +141,7 @@ } - public function accept():Boolean // true iff completely finished with module + public function accept():int // 0: not finished, 1: finished block, 2: finished module { try { @@ -156,26 +156,27 @@ currBlock = nextBlock; init(module.blocks.getItemAt(currBlock) as Block); numPages = pageDisplay.pages.length; - return false; + + return 1; } else { - //server stuff goes here + //server stuff goes here (in FisheryExperiment,actually) - return true; // module finished + return 2; // module finished } } else { Alert.show("Cannot advance.\nTry looking at every page."); } - return false; + return 0; } catch(err:Error) { Alert.show("accepterror"+err.message+err.getStackTrace()); } - return false; + return 0; } public function save():ArrayCollection Deleted: mentalmodels/trunk/flex/src/custom/TimeLabel.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/TimeLabel.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/TimeLabel.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" - creationComplete="init()"> - - <mx:Script> - <![CDATA[ - [Bindable] private var showTime:String; - - private function init():void{ - // Update every second - var tmr:Timer = new Timer(1000); - tmr.addEventListener(TimerEvent.TIMER, changeTime); - tmr.start(); - } - - private function changeTime(event:TimerEvent):void{ - // Get Server Time - var serv:Date = new Date(); // *fix this* - - // Display Server Time - showTime = serv.toLocaleTimeString(); - } - ]]> - </mx:Script> - - <mx:Label text="{showTime}"/> - -</mx:Canvas> Modified: mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml =================================================================== --- mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-16 00:23:57 UTC (rev 185) +++ mentalmodels/trunk/flex/src/custom/questions/strategyDesign/PlannerRow.mxml 2009-07-16 21:00:46 UTC (rev 186) @@ -50,11 +50,12 @@ public function getLocation():String { - if(location.selectedIndex == 0) - { - return "Harbor"; - } - return "Bay " + location.selectedIndex; + return location.selectedItem as String; +// if(location.selectedIndex == 0) +// { +// return "Harbor"; +// } +// return "Bay " + location.selectedIndex; } public function setLocation(newValue:String):void { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |