VerifyError: Error #1102: Illegal default value for type int

07 May

Stubled across an AS3 compiler bug that I've seen before, but couldn't find a good explanation via Google for. If you get the above error, make sure you don't initialize an "int" to "null". Changing it from:

public function Quad( w:Number, h:Number, color:int = null )

to:

public function Quad( w:Number, h:Number, color:int = undefined )

will remove this stupid compiler error...

4 Responses to VerifyError: Error #1102: Illegal default value for type int

  1. Offshore Software Development Company 07 May 2013 at 12:28 pm #

    The AS3 bug generally arises with the inner classes and interfaces. It is a bug of compiler. Some have tested this with Flash CS6.

  2. Simon Gladman 07 May 2013 at 1:22 pm #

    I don’t think it’s a compiler error: primitive types like int and uint can’t be null.

    simon

  3. senocular 07 May 2013 at 1:58 pm #

    im surprised undefined worked. ints should only be able to have numeric values. you should be using something like 0 or -1instead for the default.

  4. Jensa 21 May 2013 at 9:15 pm #

    @senocular True. Probably should have used -1, but I just posted this in a hurry for others to find since I didn’t find the answer by googling smile

  5.