02.25.12

ActionScript Error 1138: Required parameters are not permitted after optional parameters.

Posted in Flash at 11:35 pm by Curtis J. Morley

ActionScript Error 1138: Required parameters are not permitted after optional parameters.

ActionScript Error 1138 Description:

AS3 Error 1138 is a great Flash error. It is descriptive and tells you exactly what it means. This means that when setting up a AS3 function you must declare the required parameters before the optional or not have any optional. Both scenarios for error 1138 are shown below. Take a look at the code and it will all make sense.

Flex / Flash Error #1138 Fix:
Put your required parameters first and then your optional ones or else make them all required.

Bad Code:

function someFunc(someNum:Number = 0, someOtherNum:Number):void
{
doSomething();
}

Good Code 1:

function someFunc(someNum:Number, someOtherNum:Number = 0):void
{
doSomething();
}

Good Code 2:

function someFunc(someNum:Number, someOtherNum:Number):void
{
doSomething();
}

This should help you resolve Flex / Flash Error #1138

Thanks and as always Happy Flashing

Curtis J. Morley

Leave a Comment