08.19.08

AS3 Error #1051: Return value must be undefined.

Posted in Flash at 6:10 am by Curtis J. Morley

ActionScript 3 Error: 1051: Return value must be undefined.

ActionScript 3 Error #1051 Description:
This error is popped up when you have specified the return type of a function as "void" and then returned something like a String, Number, etc...

Flex / Flash Error #1051 Fix:

If you need to return something from this function then simply specify the return type properly.

Bad Code:

function bob():void
{
return "message";
}

Good Code:

function bob():String
{
return "message";
}

Related Errors:

Flash Error 1067 (If you specified a return type of int, uint, Number, Array, Bitmap, etc...)
Flash Warning 3590 (If you specified a return type of Boolean)
Flash Error 1046 (If you specified a return type of Button)

This should help you resolve Flex / Flash Error #1051

Thanks and as always Happy Flashing

Curtis J. Morley

Leave a Comment