2 Replies Latest reply on Aug 24, 2006 12:36 PM by Abhi910

    Silly error

    Abhi910 Level 1
      Hello,
      I am new to FLEX, am trying to do a HTTP Post and was trying the example in the documentation. Here is the code.

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script><![CDATA[
      import flash.net.*;

      public function executeSearch(event:MouseEvent):void {
      public var u:URLRequest = new URLRequest(" http://www.google.com/search?hl=en&q=" + ta1.text);
      navigateToURL(u,"_blank");
      }

      ]]></mx:Script>
      <mx:TextArea id="ta1"/>
      <mx:Button label="Search" click="executeSearch(event)"/>
      </mx:Application>

      But when i am compiling it, i get the following error

      Error 1114 : The public attribute can only be used inside a package. for the line where i declare the following - public var
      u:URLRequest

      I know its a ver silly question to ask, but please help.

      Thanks
      -Abhinav
        • 1. Re: Silly error
          peterent Level 2
          Maybe there is a typo in the documentation. It should read:

          var u:URLRequest = ....

          without the "public" scope. Since you are defining the variable within the function, it has local scope. Keywords, public, private, and protected refer to the access permissions on functions and variables at the class level. For example, the executeSearch function is publically available.
          • 2. Re: Silly error
            Abhi910 Level 1
            Thanks for your help!

            The typo is at a number of places, would be great if it could be updated.

            Thanks anyways :)