1 Reply Latest reply on Apr 24, 2008 4:39 AM by atta707

    help in setTimeout function

    smonika15
      I want to pass the argument in the function called in setTimeout function.
      Below is the code snippet.

      public function histogramDataPointClick(dataPointObj:Event):void
      {
      var duration:Number = 5000;
      setTimeout(executeEvent(dataPointObj),duration);
      }
      public function executeEvent(dataPointObj:Event ):void
      {
      var index:int;
      var message:String;
      message="";
      selectedDataPoint1=dataPointObject.currentTarget.series;

      for(var i:int = 0; i< selectedDataPoint1[0].selectedIndices.length; i++)
      {
      index=selectedDataPoint1[0].selectedIndices ;
      message = message+" "+protocolTrendData[index].valueOf().trialPhase;

      }


      Alert.show("Selected Trial Phase"+message);



      dispatchEvent(new Event("histogramDataPointClick"));
      }
      If I am trying to do that then I am facing error 1067:Implicit coercion of a value of type void to an unrelated type Function.


      error 1067

      can anybody help me in that?

      Thanks



        • 1. help in setTimeout function
          atta707 Level 2
          try:

          setTimeout(executeEvent, duration, dataPointObject);

          setTimeout () function

          public function setTimeout(closure:Function, delay:Number, ... arguments):uint

          Runs a specified function after a specified delay (in milliseconds).

          Instead of using this method, consider creating a Timer object, with the specified interval, using 1 as the repeatCount parameter (which sets the timer to run only once).

          If you intend to use the clearTimeout() method to cancel the setTimeout() call, be sure to assign the setTimeout() call to a variable (which the clearTimeout() method will later reference)


          Parameters closure:Function — The name of the function to execute. Do not include quotation marks or parentheses, and do not specify parameters of the function to call. For example, use functionName, not functionName() or functionName(param).

          delay:Number — The delay, in milliseconds, until the function is executed.

          ... arguments — An optional list of arguments that are passed to the closure function.