ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184: Incompatible default value of type int where String is expected.

ActionScript Error 1184 Description:
This error is quite simple.  It just says that you have the wrong type of data in your parameter initializer.  Or in other words you tried to assign a string where you typed the parameter as a uint.

Flex / Flash Error #1184 Fix:
Match the parameter type to the proper data type.

Bad Code 1:

bob(someValue:uint = “Happy”)
{
trace(someValue);//error 1184
}

Good Code 1:

bob(someValue:uint = 5)
{
trace(someValue);//output 5
}

Related Errors:

AS3 Error 1047

This should help you resolve Flex / Flash Error #1184

Thanks and as always Happy Flashing

Curtis J. Morley

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.

ActionScript Error 1047: Parameter initializer unknown or is not a compile-time constant.ActionScript Error 1047

Description:
Let’s break down ActionScript Error 1047 into it’s various parts.

  1. Parameter = The variable inside the parenthesis of a function
  2. Initializer = An initial value set on the parameter inside the parenthesis
  3. Compile-time Constant = Something Flash knows the value of without evaluating

So long story short – you are trying to assign a value to a parameter that has to be evaluated.  Still don’t know what I mean?  Check the code examples.

This is actually a really great feature of AS3.  Say for example you have an event listener that calls a function.  You also want to call this same function without the event. Unless you pass a value in you will get AS3 Error 1136.  AS3 allows you to set the Event parameter to null and therefore accept a call to that function without passing in a parameter.  function myUtilFunc( e:Event = null);

You can initialize and function with any Compile time constant for example a string like “Happy”, a constant like null or an int like 5 but you can not throw in anything that needs to be evaluated like a variable, math operation, an in-line array like [a,b,c] or date.

Flex / Flash Error #1047 Fix:
Remove any variable data and use only constants in the initializer such as Strings, Numbers, Null, etc…

Bad Code:

var init:String = “Happy”
function bob(someValue:String = init){
trace(someValue);
}

Good Code:

function bob(someValue:String = “Happy”){
trace(someValue);
}

or

function multiFunction(e:Event = null){
//doSomething;
}

Related Errors:

AS3 Error 1184

This should help you resolve Flex / Flash Error #1047

Thanks and as always Happy Flashing

Curtis J. Morley