1 Reply Latest reply on Dec 5, 2009 4:49 AM by chris.huston.t10

    Duplicate function error : 1021.

    frankyflex

      ello everyone, I did a search for the error and found some clues however most of the search results refer to mouse click function and my error is referring to something different.

       

      Src.

      -main.mxml : within the main.mxml files I have a tab navigator with 2 tabs. In each tab is a datagrid with a filter function.

       

      I basically merged 2 datagrid applications into one application via tab navigator.

       

      Here are the 2 scripts for each datagrid:

       

       

      <mx:Script>

      <![CDATA[

       

       

      // On startup

       

       

       

      public function initApp():void

      {

       

       

       

       

       

      myData.filterFunction=processFilter;

      }

       

       

       

       

      public function processFilter(item:Object):Boolean

      {

       

      var result:Boolean=false;

       

       

      // If no filter text, or a match, then true

       

       

       

      if (!item.ctycode.length || item.ctycode.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)

      result=

      true;

       

      if (!item.location.length || item.location.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)

      result=

      true;

       

       

      return result;

      }

      ]]>

       

      </mx:Script>

       

       

      ------Here is the 2nd ----

       

      <![CDATA[

       

       

      import mx.messaging.management.ObjectName;

       

      // On startup

       

       

       

       

      public function initApp():void

       

      {

       

       

       

       

      singleCI.filterFunction=processFilter;

      }

       

       

       

       

       

       

       

       

      public function processFilter(item:Object):Boolean

       

      {

       

      var result:Boolean=false;

       

       

      // If no filter text, or a match, then true

       

       

       

      if (!item.mainci.length || item.mainci.toUpperCase().indexOf(txtFFilter.text.toUpperCase()) >= 0)

      result=

      true;

       

       

      return result;

      }

      ]]>

       

      </mx:Script>

       

       

       

      I get 2 errors:

       

      1021: Duplicate function definition. @ "public function initApp():void"

      1021: Duplicate function definition. @ "public function processFilter(item:Object):Boolean"

       

       

       


        • 1. Re: Duplicate function error : 1021.
          chris.huston.t10 Level 3

          Functions must have unique names in your application, but you have two functions with the same names, which is causing your error. You can combine the first function into one function and then just change the names of your second function as shown below.

           

          Chris

           

          <mx:Script>

          <![CDATA[

          public function initApp():void

          {

          myData.filterFunction=processFilter;

          singleCI.filterFunction=processFilter2;

          }

           

          public function processFilter(item:Object):Boolean

          {

           

          var result:Boolean=false;

          if (!item.ctycode.length || item.ctycode.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)

          result=

          true;

           

          if (!item.location.length || item.location.toUpperCase().indexOf(txtFilter.text.toUpperCase()) >= 0)

          result=

          true;

           

          return result;

          }

           

          public function processFilter2(item:Object):Boolean

           

          {

           

          var result:Boolean=false;

           

          if (!item.mainci.length || item.mainci.toUpperCase().indexOf(txtFFilter.text.toUpperCase()) >= 0)

          result=

          true;

           

           

          return

          result;

          }

          ]]>

           

          </mx:Script>

           

          1 person found this helpful