4 Replies Latest reply on Aug 6, 2009 8:28 AM by Gregory Lafrance

    problems with the textinput control

    karlmons

      Hello Everyone,

       

      I am currently in the process of creating an Air based web browser, but I have come across one little issue that I can't seem to get passed. When you enter the web address in the address bar normally, i.e. http://www.adobe.com, it works fine. However if you enter it as adobe.com without the http it defaultly goes to app:/adobe.com. Is there anyway to change this? All help is appreciated. I have included a snippet of my code so you can get a better picture.

       

         //this is the main code that deals with the textinput//
      
                              <mx:TextInput id="txtURL" text="http://www.google.com" 
                     editable="true" enabled="true"
                     change="changeInput(event);"
                     textInput="urlTextInput(event)"
                     enter="urlEnter(event)"/>
      
      //other code here.//
      
                               private function urlTextInput(event:TextEvent):void {
                          // trace("urlTextInput event:"+event.text);
                          if (!this.bUserEditingLocation)
                          {
                            trace("Setting bUserEditingLocation = true");
                            this.bUserEditingLocation =true;
                          }
                     }
      
                     private function urlEnter(event:Event):void {
                          trace("urlEnter");
                          if (webbrowser.location != txtURL.text)
                          {
                          trace("bUserEditingLocation = false and setting location to "+txtURL.text);
                          webbrowser.htmlLoader.cancelLoad();
                          webbrowser.location =      txtURL.text;
                          bUserEditingLocation = false;
                          focusManager.setFocus(webbrowser);
                          }
                     }
      
                     private function changeInput(event:Event):void {
                     }
      
                     private function SetURLTextInput(S:String):void
                     {
                          trace("SetURLTextInput to "+S);
                          txtURL.text = S;
                     }
      
                     private function browserComplete(event:Event):void {
                          if (txtURL.text != webbrowser.location)
                          {
                               if (!IsUserEditingLocation())
                          {
                               trace("BrowserComplete setting new location to text input "+ webbrowser.location);
                               SetURLTextInput(webbrowser.location);
      
                          }
                          else
                          {
                              trace("BrowserComplete while user is editing");
                          }
                     }
                          else
                          {
                               trace("BrowserComplete to same location");
                          }
      
                         // Stop the marching dots, and return to the default text and color.
                         bLocationChanging = false;
                          lblURL.setStyle("color",DefaultButtonColor);
                          lblURL.text = DefaultButtonText;
                     }