0 Replies Latest reply on Mar 23, 2011 3:33 PM by hitenjava123

    IndexOutOfBoundsException error on compile

    hitenjava123

      Came across an error which took me hours to locate the cause.

       

      Something like the code below compiles fine:

       

      public function function1():void{
                      obj.addEventListener(MyEvent.
                          MY_EVENT_TYPE,
                          function onEvent(event:Event):void {

                                    function2(classname);
                      });
      }


      public function function2(className:String):void{
                      var objClass:Class =
                              getDefinitionByName(classNameStr) as Class;
                          if (objClass != null) {
                              myContent = (UIComponent(new objClass()));
                          }
      }

       

      But if I put the code in the same function instead, it throws up an error on compiling (without even specifying the class which has the error.)

      The code:
      public function function1():void{
                      obj.addEventListener(MyEvent.
                          MY_EVENT_TYPE,
                          function onEvent(event:Event):void {
                          var objClass:Class = getDefinitionByName(classNameStr) as Class;
                          if (objClass != null) {
                                   myContent = (UIComponent(new objClass()));
                          }
                      });
      }

      The error:

      -----------------------

      compile-application:

           [exec] Loading configuration file C:\...\flex\frameworks\fl

      ex-config.xml

           [exec] Error: Index: 16, Size: 16

           [exec]

           [exec] java.lang.IndexOutOfBoundsException: Index: 16, Size: 16

           [exec]     at java.util.ArrayList.RangeCheck(Unknown Source)

           [exec]     at java.util.ArrayList.get(Unknown Source)

           [exec]     at macromedia.asc.semantics.ReferenceValue.getSlot(ReferenceValu

      e.java:253)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluateGenericCallExp

      ression(LintEvaluator.java:202)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:379)

           [exec]     at macromedia.asc.parser.CallExpressionNode.evaluate(CallExpress

      ionNode.java:46)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1025)

           [exec]     at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExp

      ressionNode.java:57)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1268)

           [exec]     at macromedia.asc.parser.ArgumentListNode.evaluate(ArgumentListN

      ode.java:45)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluateGenericCallExp

      ression(LintEvaluator.java:269)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:454)

           [exec]     at macromedia.asc.parser.CallExpressionNode.evaluate(CallExpress

      ionNode.java:46)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1025)

           [exec]     at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExp

      ressionNode.java:57)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1324)

           [exec]     at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1310)

           [exec]     at macromedia.asc.parser.ArgumentListNode.evaluate(ArgumentListN

      ode.java:45)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:875)

           [exec]     at macromedia.asc.parser.SetExpressionNode.evaluate(SetExpressio

      nNode.java:58)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1025)

           [exec]     at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExp

      ressionNode.java:57)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1324)

           [exec]     at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1398)

           [exec]     at macromedia.asc.parser.ExpressionStatementNode.evaluate(Expres

      sionStatementNode.java:50)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1346)

           [exec]     at macromedia.asc.parser.StatementListNode.evaluate(StatementLis

      tNode.java:60)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1438)

           [exec]     at macromedia.asc.parser.IfStatementNode.evaluate(IfStatementNod

      e.java:50)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1346)

           [exec]     at macromedia.asc.parser.StatementListNode.evaluate(StatementLis

      tNode.java:60)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1867)

           [exec]     at macromedia.asc.parser.FunctionCommonNode.evaluate(FunctionCom

      monNode.java:104)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:1848)

           [exec]     at macromedia.asc.parser.FunctionCommonNode.evaluate(FunctionCom

      monNode.java:104)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:2321)

           [exec]     at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefin

      itionNode.java:106)

           [exec]     at macromedia.asc.embedding.LintEvaluator.evaluate(LintEvaluator

      .java:2042)

           [exec]     at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:8

      0)

           [exec]     at flex2.compiler.as3.Compiler.analyze4(Compiler.java:611)

           [exec]     at flex2.compiler.API.analyze(API.java:2542)

           [exec]     at flex2.compiler.API.analyze(API.java:2432)

           [exec]     at flex2.compiler.API.batch2(API.java:411)

           [exec]     at flex2.compiler.API.batch(API.java:1117)

           [exec]     at flex2.compiler.API.compile(API.java:1290)

           [exec]     at flex2.compiler.API.compile(API.java:1210)

           [exec]     at flex2.tools.Compiler.mxmlc(Compiler.java:275)

           [exec]     at flex2.tools.Compiler.main(Compiler.java:53)

       

      BUILD FAILED