Skip navigation
Currently Being Moderated

Static function parameter help

Apr 12, 2012 11:07 AM


I have two functions in the same file, how can I use the first function as default value in the second function.


public static function get decimalFormatter1():NumberFormatter{




I try this:

public static function secondFunction(param1:String, param2:Int=0, param3:Function=decimalFormatter1):Array{



Getting error: -1047: Parameter initializer unknown or is not a compile-time constant.


Any ideas?


  • Currently Being Moderated
    Apr 12, 2012 12:32 PM   in reply to jfb00

    decimalFormatter1 is a getter, so when you write the parameter


        param3:Function = decimalFormatter


    the default value is the result of calling the getter (i.e., it is the NumberFormatter returned by the getter); it isn't a Function. There is no way to treat a getter or setter as a Function object.


    Gordon Smith, Adobe

    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 12:34 PM   in reply to GordonSmith

    As a workaround, you could use null as a default value, where null means "use decimalFormatter1". You'd write something like


    public static function secondFunction(param1:String, param2:int = 0, param3:Function = null):Array

        var formatter:Function = null;


        if (param3 == null)

            formatter = decimalFormatter1;




    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points