topical media & game development

talk show tell print

lib-flex-ximpel-editor-net-ximpel-components-SubjectForm.mx

lib-flex-ximpel-editor-net-ximpel-components-SubjectForm.mx (swf ) [ flash ] flex


  <?xml version="1.0" encoding="utf-8"?>
  <!-- 
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
          Javier Quevedo Fernández 05-2009.
  -->
  <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
           horizontalScrollPolicy="off">
          <mx:Script>
                  <![CDATA[
                          [bindable]
                          public var subjectView : SubjectView;
                  ]]>
          </mx:Script>
          <mx:Label y="-1" text="Subject Inspector" fontWeight="bold"/>
           <mx:Form id="form" y="20" width="100%" >
  
          <mx:FormItem label="Id" width="198">
              <mx:TextInput id="subjectId" width="118" valueCommit="formChangeHandler(event);" />
          </mx:FormItem>
           <mx:FormItem label="Description" width="198">
              <mx:TextInput id="description"  width="118" valueCommit="formChangeHandler(event);"/>
          </mx:FormItem>   
          <mx:FormItem label="Score" width="198">
                          <mx:DataGrid id="scoresDataGrid"  
                                  editable="true" height="101" width="117">
                                          <mx:columns>
                                                          <mx:DataGridColumn width="200" headerText = "Type" dataField="type" textAlign="right"/>
                                                          <mx:DataGridColumn width="200" headerText = "Points" dataField="points" textAlign="right"/>
                                          </mx:columns>
                                  </mx:DataGrid>
          </mx:FormItem>   
                    <mx:FormItem label="" width="198">
                            <mx:HBox>
                                    <mx:LinkButton label="Add" click="linkAddScoreHandler(event)"/>
                                    <mx:LinkButton label="Remove" click="onRemoveScore(event)" />
                            </mx:HBox>
                   </mx:FormItem>
          <mx:FormItem label="Leads to" width="198">
              <mx:ComboBox id="leadsTo" width="118" valueCommit="formChangeHandler(event);"/>
          </mx:FormItem>
      
      </mx:Form>
          <mx:Script>
          <![CDATA[
          import mx.events.MoveEvent;
          import net.ximpel.events.InterfaceEvents;
          import net.ximpel.classes.*
          
              private function processValues(zip:String, pn:String):void {
                  // Validate and process data.
              }
                 
                         private function comboBoxOpenHandler (event:Event):void{
                                 dispatchEvent(new InterfaceEvents("subjectComboBoxOpen"));
                         }
                 
                         private function formChangeHandler(event:Event):void{
                                 if (validateForm(event))
                                         dispatchEvent(new InterfaceEvents("subjectFormChanged"));
                         }
                 
                         private function validateForm(event:Event):Boolean{
                                 return true;
                         }            
          
              private function toId(element:Subject, index:int, arr:Array):String {
                  return element.id;
              }
               private function toScore(element : Number, index:int, arr:Array):Object {
                  var output : Object = new Object();
                  output.Value = element;
                  return output;
              }                      
                         public function updateSubject():void {
                                 if (leadsTo.selectedIndex != -1)
                                         subjectView.subject.leadsTo = leadsTo.selectedItem as String;
                                 subjectView.subject.id = subjectId.text;
                                 subjectView.subject.description= description.text;        
                         }
                         public function updateForm(subject : Subject, subjects : Array):void {
                                 subjectId.text = subject.id;
                                 description.text = subject.description;
                                  leadsTo.dataProvider = subjects.map(toId);  
                                  leadsTo.selectedIndex = -1;
                                  leadsTo.prompt = subject.leadsTo;        
                                  scoresDataGrid.dataProvider = subject.scores;        
                          }
                          
                          private function linkAddScoreHandler(event:Event):void{
                                  var score : Score = new Score(0,"type");
                                  this.subjectView.subject.addScore(score);
                                  scoresDataGrid.dataProvider = this.subjectView.subject.scores;        
                          }
                          
                          private function onRemoveScore(event:Event):void{
                                  this.subjectView.subject.removeScore(scoresDataGrid.selectedIndex);
                                  scoresDataGrid.dataProvider = this.subjectView.subject.scores;        
                          }
                          
          ]]>
      </mx:Script>
  
  </mx:Canvas>
  


(C) Æliens 18/6/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.