3 Replies Latest reply on Apr 5, 2011 11:50 AM by Gio Nadirashvili

    Error 1137 with timer sample


      I am facing error 1137 - Incorrect number of arguments. Expected no more than 0. in the example from Flex 2 Developer's Guide page 1606 and 1607

      To make things easier I copy here the code I use:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="initTimer()">
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import mx.collections.ArrayCollection;
      public var memoryUsage:ArrayCollection = new ArrayCollection();

      public function initTimer():void
      // The first parameter in the Timer constructor
      // is the interval, in milliseconds.
      // The second parameter is how many times to run (0 is
      // infinity).

      var myTimer:Timer = new Timer(1000, 0);
      // Add the listener for the timer event.
      myTimer.addEventListener("timer", timerHandler);

      public function timerHandler(event:TimerEvent):void
      var o:Object = new Object();
      // Get the number of milliseconds since Flash Player started.
      o.time = getTimer();
      // Get the total memory Flash Player is using.
      o.memory = flash.system.System.totalMemory;
      trace(o.time + ":" + o.memory);
      // Add new object to the ArrayCollection, which is bound
      // to the chart's data provider.


      <mx:LineChart id="chart" dataProvider="{memoryUsage}" showDataTips="true">
      <mx:LinearAxis minimum="5000000"/>
      <mx:LineSeries yField="memory"/>

      The following line raises Error 1137:

      var myTimer:Timer = new Timer(1000, 0);

      I am running Flex Builder on Mac OS X.

      Your help is highly appreciated!


        • 1. Re: Error 1137 with timer sample
          volatus Level 1
          Your help is still highly appreciated!
          • 2. Re: Error 1137 with timer sample

            I realize this is VERY old, but for some unknown reason my boss is having the same problem.  So, if he does this:


            import flash.utils.Timer;


            private var t:Timer = new Timer(1000, 0);


            He gets an argument count mismatch (the compiler wants 0 arguments for the constructor).  BUT, if he does this:


            private var t:flash.utils.Timer = new flash.utils.Timer(1000, 0);


            Then it works perfectly fine.  I'm not really sure what the error is, as far as I can tell he has the same installation as the developers (and it works fine for us).  I mean, we have the above fix (which is fine), but it would be less combersome if the import actually worked as expected so that our boss didn't think we were trying to pass off non-compilable code.

            • 3. Re: Error 1137 with timer sample
              Gio Nadirashvili

              I understand this is WAY old post but I get the same error when defining Timer object. any help?