[virtualcommons-svn] SF.net SVN: virtualcommons:[163] mentalmodels/trunk/flex/src
Status: Beta
Brought to you by:
alllee
From: <kj...@us...> - 2009-06-16 22:08:59
|
Revision: 163 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=163&view=rev Author: kjonas Date: 2009-06-16 22:08:55 +0000 (Tue, 16 Jun 2009) Log Message: ----------- renamed ForecastQuestion.mxml to ForecastingQuestionC.mxml added loadFromQuestion() functions to all *QuestionC.mxml files these functions do not work, must fix beans for *Question.as files first Modified Paths: -------------- mentalmodels/trunk/flex/src/QuestionTest.mxml mentalmodels/trunk/flex/src/TestForecast.mxml mentalmodels/trunk/flex/src/_InstructionsTest.mxml mentalmodels/trunk/flex/src/actionscript/PageDisplay.as mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml Added Paths: ----------- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml Removed Paths: ------------- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml Modified: mentalmodels/trunk/flex/src/QuestionTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/QuestionTest.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -42,6 +42,6 @@ <comp:TextQuestionC id="question1"/> <comp:CategoricalQuestionC id="question2" topics="{topicList}" specifics="{specificList}"/> - <comp:ForecastQuestion id="question3"/> + <comp:ForecastingQuestionC id="question3"/> </mx:Application> Modified: mentalmodels/trunk/flex/src/TestForecast.mxml =================================================================== --- mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/TestForecast.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -56,7 +56,10 @@ { try { + forecastComponent0.load(forecastSaved); forecastComponent1.load(forecastSaved); + forecastComponent2.load(forecastSaved); + forecastComponent3.load(forecastSaved); planner.load(plannerSaved); } Modified: mentalmodels/trunk/flex/src/_InstructionsTest.mxml =================================================================== --- mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/_InstructionsTest.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" layout="vertical" xmlns:as="actionscript.*"> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" xmlns:as="actionscript.*" + layout="vertical"> <mx:Script> <![CDATA[ + import actionscript.Question; + import actionscript.CategoricalQuestion; import actionscript.QuestionGroup; import actionscript.PsychometricQuestion; import actionscript.Block; + import mx.collections.ArrayCollection; public var choices1:ArrayCollection = new ArrayCollection(); public var questions1:ArrayCollection = new ArrayCollection(); @@ -18,39 +22,37 @@ public function fillBlock():void { try{ -// debg.text += "creating choices\n"; - choices1.addItem("Highly Agree"); - choices1.addItem("Highly Neutral"); - choices1.addItem("Highly Disagree"); + // create questions + var psy1:PsychometricQuestion = new PsychometricQuestion(); + psy1.numberOfIntervals = 10; + psy1.choices = new ArrayCollection(); + psy1.choices.addItem("Highly Agree"); + psy1.choices.addItem("Highly Neutral"); + psy1.choices.addItem("Highly Disagree"); - choices2.addItem("Agree"); - choices2.addItem("Neutral"); -// debg.text += "choices1.length="+choices1.length+"\n"; + var psy2:PsychometricQuestion = new PsychometricQuestion(); + psy2.numberOfIntervals = 10; + psy2.choices = new ArrayCollection(); + psy2.choices.addItem("Agree"); + psy2.choices.addItem("Neutral"); -// debg.text += "creating questions\n"; - questions1.addItem(new PsychometricQuestion()); - PsychometricQuestion(questions1.getItemAt(0)).choices = choices1; - PsychometricQuestion(questions1.getItemAt(0)).numberOfIntervals = 3; + // insert questions into groups + var qg1:QuestionGroup = new QuestionGroup(); + qg1.questions = new ArrayCollection(); + qg1.questions.addItem(psy1); - questions2.addItem(new PsychometricQuestion()); - PsychometricQuestion(questions2.getItemAt(0)).choices = choices2; - PsychometricQuestion(questions2.getItemAt(0)).numberOfIntervals = 5; -// debg.text += "questions1.length="+questions1.length+"\n"; + var qg2:QuestionGroup = new QuestionGroup(); + qg2.questions = new ArrayCollection(); + qg2.questions.addItem(psy2); +// throw new Error("test"); -// debg.text += "creating questiongroups\n"; - questionGroups1.addItem(new QuestionGroup()); - questionGroups1.addItem(new QuestionGroup()); - QuestionGroup(questionGroups1.getItemAt(0)).questions = questions1; - QuestionGroup(questionGroups1.getItemAt(1)).questions = questions2; -// debg.text += "questionGroups.length="+questionGroups.length+"\n"; + block1.questionGroups = new ArrayCollection(); + block1.questionGroups.addItem(qg1); + block1.questionGroups.addItem(qg2); -// debg.text += "creating block\n"; - block1.questionGroups = questionGroups1; -// debg.text += "block1.questionGroups.length="+block1.questionGroups.length+"\n"; - // debg.text += "finished\n"; }catch(errObject:Error){ - debg.text += "block creation failure\n" + + debug.text += "block creation failure\n" + errObject.message + "\n" + errObject.getStackTrace(); } } @@ -58,18 +60,18 @@ ]]> </mx:Script> - <mx:ArrayCollection id="labs"> + <!--<mx:ArrayCollection id="labs"> <mx:String>testLeft</mx:String> <mx:String>testRight</mx:String> <mx:String>testRight</mx:String> </mx:ArrayCollection> <comp:PsychometricQuestionC id="psych" labels="{labs}" initialize="true"/> - <comp:CategoricalQuestionC/> + <comp:CategoricalQuestionC/>--> <mx:Button id="forward" click="iPage.forward()" label="forward"/> <mx:Button id="back" click="iPage.back()" label="back"/> - <mx:Text id="debg" text=""/> + <mx:Text id="debug" text=""/> <comp:InstructionPage id="iPage" preinitialize="fillBlock()" initialize="iPage.init(block1)"/> Modified: mentalmodels/trunk/flex/src/actionscript/PageDisplay.as =================================================================== --- mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/actionscript/PageDisplay.as 2009-06-16 22:08:55 UTC (rev 163) @@ -1,6 +1,9 @@ // ActionScript file package actionscript { + import customComponents.TextQuestionC; + import customComponents.ForecastingQuestionC; + import customComponents.CategoricalQuestionC; import customComponents.PsychometricQuestionC; import flash.display.DisplayObject; @@ -10,24 +13,11 @@ import mx.controls.ComboBox; import mx.controls.Label; import mx.controls.Text; - import mx.controls.TextArea; [Bindable] public class PageDisplay { - /* - pages:ArrayCollection should be a bunch of VBoxes. - The structure of an element of the pages:ArrayCollection is as follows: - (element / type / description) - - 0 / Label / this is the header - 1 / Text / description (USE THIS FOR INSTRUCTION PAGES) - - 2+2*N / Label / question description for N'th question - 3+2*N / TextArea,ComboBox,PsychometricQuestion,Forecasting / the question itself - - */ public var msg:String = ""; public var pages:ArrayCollection; @@ -79,43 +69,36 @@ txt.htmlText = tempQuestion.question; tempBox.addChild(txt); - if(tempQuestion is actionscript.ForecastingQuestion) + if(tempQuestion is ForecastingQuestion) { - // ??? how is this going to be worked in ??? - //tempBox.addChild(new mx.containers.HBox()); + var fq:ForecastingQuestionC = new ForecastingQuestionC(); + fq.loadFromQuestion(ForecastingQuestion(tempQuestion)); + fq.id = "q"+question; + + tempBox.addChild(fq); } - else if(tempQuestion is actionscript.CategoricalQuestion) + else if(tempQuestion is CategoricalQuestion) { - var tempCat:CategoricalQuestion = CategoricalQuestion(tempQuestion); - var cq:ComboBox = new ComboBox(); + var cq:CategoricalQuestionC = new CategoricalQuestionC(); + cq.loadFromQuestion(CategoricalQuestion(tempQuestion)); cq.id = "q"+question; - cq.dataProvider = tempCat.choices; - cq.initialize(); + tempBox.addChild(cq); } - else if(tempQuestion is actionscript.PsychometricQuestion) + else if(tempQuestion is PsychometricQuestion) { - var tempPsych:actionscript.PsychometricQuestion = actionscript.PsychometricQuestion(tempQuestion); - var pq:customComponents.PsychometricQuestionC = new customComponents.PsychometricQuestionC(); + var pq:PsychometricQuestionC = new PsychometricQuestionC(); + pq.loadFromQuestion(PsychometricQuestion(tempQuestion)); pq.id = "q"+question; - pq.labels = tempPsych.choices; - pq.maxValue = tempPsych.numberOfIntervals; - pq.initialize(); - pq.init(); // ERROR FOUND SOMEWHERE IN HERE - -/* var e:Error = new Error(); -e.message = "TEST"; -throw e; */ tempBox.addChild(pq); } else { - var tq:TextArea = new TextArea(); + var tq:TextQuestionC = new TextQuestionC(); + tq.loadFromQuestion(Question(tempQuestion)); tq.id = "q"+question; - tq.width = 150; - tq.height = 14; - tq.initialize(); + tempBox.addChild(tq); } } Modified: mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/CategoricalQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,9 +1,32 @@ <?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" + dataProvider="{topics}" selectedIndex="0"/> + <mx:ComboBox id="comboSpecific" + dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> + </mx:HBox> + <mx:Script> <![CDATA[ import actionscript.FishUtil; + import actionscript.CategoricalQuestion; private function fix(index:int, list:ArrayCollection):int { @@ -24,31 +47,17 @@ comboSpecific.selectedIndex = loadArray.getItemAt(1) as int; } + public function loadFromQuestion(question:CategoricalQuestion):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> - <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" - dataProvider="{topics}" selectedIndex="0"/> - <mx:ComboBox id="comboSpecific" - dataProvider="{specifics.getItemAt(fix(comboTopic.selectedIndex, specifics))}"/> - </mx:HBox> - <!-- the selected element of this array determines which of the elements of "specifics" will be used as the dataProvider --> <mx:ArrayCollection id="topics"> Modified: mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/ForecastComponent.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -29,7 +29,7 @@ [Bindable] public var finished:Boolean = false; // for lining up grids - [Bindable] public var minimumWidth:int = 30; + [Bindable] public var minimumWidth:int = 160; // // public accessible functions Deleted: mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/ForecastQuestion.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> - - <mx:Label id="header"/> - <comp:Forecast1 id="forecastPeople" numColumns="15" minValue="0" maxValue="30" initialize="init()"/> - <mx:Button id="next" label="Next" click="testNext()"/> - - <mx:Script> - <![CDATA[ - import customComponents.*; - import mx.collections.ArrayCollection; - - public function init():void - { - for(var x:int=0;x<4;x++)for(var y:int=0;y<15;y++)forecastPeople.setItem(x,y,7.5); - } - - public function testNext(evt:Event=null):void - { - if(!forecastPeople.isFinished()) return; - var f2:Forecast2 = new Forecast2(); - f2.id = "forecastFull_AS"; - f2.numColumns = 6; - f2.oldForecast1 = forecastPeople; - this.addChild(f2); - } - - ]]> - </mx:Script> - -</mx:VBox> Added: mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml (rev 0) +++ mentalmodels/trunk/flex/src/customComponents/ForecastingQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> + + <mx:String id="description"></mx:String> + <mx:VBox id="headers"> + <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()"/> + <mx:Button id="btnBack" label="Forecast People" click="back()" enabled="false"/> + </mx:HBox> + + <mx:VBox id="content"/> + + <mx:Script> + <![CDATA[ + import actionscript.ForecastingQuestion; + import mx.collections.ArrayCollection; + + public var style0:ForecastComponent; + public var style1:ForecastComponent; + public var style2:ForecastComponent; + public var style3:ForecastComponent; + + public var peopleSaved:ArrayCollection; + public var fishSaved:ArrayCollection; + + public var numBays:int = 3; + public var numColumnsMin:int = 6; + public var numColumnsMax:int = 15; + + public function init():void + { + createStyle(style0,0); + createStyle(style1,1); + createStyle(style2,2); + createStyle(style3,3); + content.addChild(style0); + } + private function createStyle(style:ForecastComponent,styleNum:int):void + { + style = new ForecastComponent(); + style.style = styleNum; + style.numBays = numBays; + if(styleNum <= 1) + { + style.numColumns = numColumnsMax; + } + else + { + style.numColumns = numColumnsMin; + } + style.initialize(); + style.init(); + } + + public function back():void + { + fishSaved = style2.save(); + content.removeAllChildren(); + content.addChild(style0); + } + public function forward():void + { + peopleSaved = style0.save(); + style1.load(peopleSaved); + content.removeAllChildren(); + content.addChild(style2); // 2:FishEntry + content.addChild(style1); // 1:PeopleView + content.addChild(style3); // 3:Calculated + } + public function accept():Boolean + { + return true; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(null); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + (loadArray.getItemAt(0) as Object); + } + + public function loadFromQuestion(question:ForecastingQuestion):void + { + description = question.question; + + initialize(); + init(); + } + + ]]> + </mx:Script> + +</mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -80,6 +80,18 @@ return false; } + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(block); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + block = (loadArray.getItemAt(0) as Block); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/InstructionPage_TEMP.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -52,11 +52,11 @@ </mx:VBox> <mx:VBox id="p1"> <mx:Text htmlText="<b><font size="16">Sample Questions</font></b>" width="300"/> - <comp:PsychometricQuestionC id="psychometricQuestion" title="Overall, how much do you like your group?" + <comp:PsychometricQuestionC id="psychometricQuestion" description="Overall, how much do you like your group?" labels="{psychometricLabels}" maxValue="3"/> <comp:CategoricalQuestionC id="categoricalQuestion" title="What goals did you follow when designing your strategy?" topics="{categoricalTopics}" specifics="{categoricalSpecifics}"/> - <comp:TextQuestionC id="textQuestion" title="Describe in your own words what the rule, agreement, or other coordination attempt states." + <comp: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"/> </mx:VBox> </mx:HBox> Modified: mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/PlannerPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -2,7 +2,7 @@ <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*"> <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, and 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." + <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/> Modified: mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/PsychometricQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="customComponents.*" initialize="false"> - <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[ @@ -29,6 +27,7 @@ <mx:Script> <![CDATA[ + import actionscript.PsychometricQuestion; import mx.collections.ArrayCollection; public var labels:ArrayCollection; @@ -98,6 +97,14 @@ slider1.sliderButton.move(loadArray.getItemAt(1) as Number, 0); } + public function loadFromQuestion(question:PsychometricQuestion):void + { + description = question.question; + + initialize(); + init(); + } + ]]> </mx:Script> Modified: mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/SocioDemographicPage.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> -<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> +<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center"> <mx:Script> <![CDATA[ + import mx.collections.ArrayCollection; public function getGender():String { @@ -28,77 +29,109 @@ // if any field is of improper length, this section is not completed // flag/unflag an area with red if incomplete/complete var ready:Boolean=true; + var bgcolor:String = "backgroundColor"; + var red:String = "#FF0000"; + var white:String = "#FFFFFF"; - if(getGender().length != 1) + if(getGender().length != 1) // "M", "F", "Err" { - boxGender.setStyle("backgroundColor", "#FF0000"); + boxGender.setStyle(bgcolor, red); ready=false; }else{ - boxGender.setStyle("backgroundColor", ""); + boxGender.setStyle(bgcolor, white); } if(getYear().length != 4 || Number(getYear()) < 1900) { - txtYear.setStyle("backgroundColor", "#FF0000"); + txtYear.setStyle(bgcolor, red); ready=false; }else{ - txtYear.setStyle("backgroundColor", "#FFFFFF"); + txtYear.setStyle(bgcolor, white); } if(getMajor().length == 0) { - txtMajor.setStyle("backgroundColor", "#FF0000"); + txtMajor.setStyle(bgcolor, red); ready=false; }else{ - txtMajor.setStyle("backgroundColor", "#FFFFFF"); + txtMajor.setStyle(bgcolor, white); } if(getSemester().length == 0) { - txtSemester.setStyle("backgroundColor", "#FF0000"); + txtSemester.setStyle(bgcolor, red); ready=false; }else{ - txtSemester.setStyle("backgroundColor", "#FFFFFF"); + txtSemester.setStyle(bgcolor, white); } - boxGender.enabled = !ready; - txtYear.enabled = !ready; - txtMajor.enabled = !ready; - txtSemester.enabled = !ready; - // all datamembers are the desired length + enable(!ready); return ready; } + public function enable(enabled:Boolean=true):void + { + boxGender.enabled = enabled; + txtYear.enabled = enabled; + txtMajor.enabled = enabled; + txtSemester.enabled = enabled; + } + + public function save():ArrayCollection + { + var saveArray:ArrayCollection = new ArrayCollection(); + saveArray.addItem(getGender()); + saveArray.addItem(getYear()); + saveArray.addItem(getMajor()); + saveArray.addItem(getSemester()); + return saveArray; + } + + public function load(loadArray:ArrayCollection):void + { + var gender:String = (loadArray.getItemAt(0) as String); + if(gender != null && gender.length == 1) + { + radioMale.selected = (gender == "M"); + radioFemale.selected = (gender == "F"); + } + txtYear.text = (loadArray.getItemAt(1) as String); + txtMajor.text = (loadArray.getItemAt(2) as String); + txtSemester.text = (loadArray.getItemAt(3) as String); + } + ]]> </mx:Script> - <mx:VBox width="220" horizontalAlign="center"> - <mx:Label text="Personal Data" fontSize="18"/> - <mx:Label text="Please fill out the following fields:"/> + <mx:VBox id="content"> + <mx:VBox width="220" horizontalAlign="center"> + <mx:Label text="Personal Data" fontSize="18"/> + <mx:Label text="Please fill out the following fields:"/> + </mx:VBox> + + <mx:HBox> + <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> + <mx:HBox id="boxGender"> + <mx:RadioButtonGroup id="gender"/> + <mx:RadioButton groupName="{gender}" label="M" id="radioMale"/> + <mx:RadioButton groupName="{gender}" label="F" id="radioFemale"/> + </mx:HBox> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtYear" width="75" maxChars="4"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtMajor" width="120" maxChars="100"/> + </mx:HBox> + + <mx:HBox> + <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> + <mx:TextInput id="txtSemester" width="75" maxChars="6"/> + </mx:HBox> </mx:VBox> - <mx:HBox> - <mx:Label text="Gender:" fontWeight="bold" width="100" textAlign="right"/> - <mx:HBox id="boxGender"> - <mx:RadioButtonGroup id="gender"/> - <mx:RadioButton groupName="{gender}" label="M" id="radioMale"/> - <mx:RadioButton groupName="{gender}" label="F" id="radioFemale"/> - </mx:HBox> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Year of Birth:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtYear" width="75" maxChars="4"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Major:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtMajor" width="120" maxChars="100"/> - </mx:HBox> - - <mx:HBox> - <mx:Label text="Semester:" fontWeight="bold" width="100" textAlign="right"/> - <mx:TextInput id="txtSemester" width="75" maxChars="6"/> - </mx:HBox> - </mx:VBox> Modified: mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml =================================================================== --- mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-16 22:08:11 UTC (rev 162) +++ mentalmodels/trunk/flex/src/customComponents/TextQuestionC.mxml 2009-06-16 22:08:55 UTC (rev 163) @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> - <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[ @@ -24,6 +22,7 @@ <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; + import actionscript.Question; public function save():ArrayCollection { @@ -37,6 +36,14 @@ textAnswer.text = loadArray.getItemAt(0) as String; } + public function loadFromQuestion(question:Question):void + { + description = question.question; + + initialize(); +// init(); + } + ]]> </mx:Script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |