topical media & game development

talk show tell print

professional-flex-code-12-SmartTextInput.mx

professional-flex-code-12-SmartTextInput.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
          <mx:Script>
                  <![CDATA[
                          import mx.collections.ArrayCollection;
                          
                          private var mySO:SharedObject;
                          private var temp:ArrayCollection = new ArrayCollection();
                          
                          [Bindable]
                          private var cBoxData:ArrayCollection = new ArrayCollection();
                                  
                          private function init():void{
                                  mySO = SharedObject.getLocal("mySO");
                          }
                          
                          private function getSO():void{
                                  temp=mySO.data.a;
                                  if(temp.length > 0 && input.text.length < 1){
                                          cBoxData = ArrayCollection(temp);
                                          cBoxData.addItem(null);
                                          cBox.visible=true;
                                          cBox.selectedIndex=mySO.data.a.length+1;
                                          cBox.open();
                                  }
                                  
                          }        
  
                          private function addToSO():void{
                                  temp.addItem({"label":input.text});
                                  mySO.data.a = temp;
                          }
                          private function updateTI(s:String):void{
                                  input.text = s;
                                  cBox.visible=false;
                          }
                          
                          private function showDrop():void{
                                  cBox.visible=false;
                                  if(input.text.length < 1){
                                          openCB();
                                  }
                          }
                          private function doubleC():void{
                                  openCB();
                          }
                          private function openCB():void{
                                  cBox.visible=true;
                                  cBox.selectedIndex=mySO.data.a.length+1;
                                  cBox.open();
                          }
                  ]]>
          </mx:Script>
          <mx:ComboBox width="200" id="cBox" dataProvider="{cBoxData}" visible="false" change="updateTI(event.target.selectedItem.label)"/>
          <mx:TextInput width="200" id="input" focusIn="getSO()" change="showDrop()" doubleClickEnabled="true" doubleClick="doubleC()" />
          <mx:Button click="addToSO()" label="Submit" x="199"/>
  </mx:Canvas>
  


(C) Æliens 04/09/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.