ActionScript 3 Warning: 1102: null used where a int value was expected.

ActionScript 3 Warning#1102 Description:
This warning is pretty good at describing what is happening but is needs to add a little to explain why. This error will appear when you try and force a variable to be a certain Type within a predefined function. For example if you have a variable like _minute below

Flex / Flash Warning1102 Fix:
Find where you are using null and make sure that you are using the proper value

Bad Code:

    var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=null);

    or

    var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute="10");

    or

    var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=false);

Good Code :

var TargetDate:Date = new Date(_year, _month, _date, _hour, _minute=10);

Warning:
You will not get this error with the code below even though it seems like the same as the code above. The smart folks at Adobe put in logic that will accommodate for numbers-as-strings and also boolean which will result in the number 0. The AS3 Warning will will only show when you assign an non-permitted variable within the parameters of a method call. The code below will output a valid date. Direct assignment in quotes will be translated into a valid Number not an int. False shows up as 0 in the date.

var TargetDate:Date = new Date(_year, _month, _date, false, "10");

About Judah

Please note in the comments if this has helped you or not.
This entry was posted in Compiler Warnings. Bookmark the permalink.

2 Responses to ActionScript 3 Warning: 1102: null used where a int value was expected.

  1. curtismorley.com » ActionScript Error #1067 - Implicit coercion of a value of type void to an unrelated type Function. says:

    […] Related Error: Flash / Flex Error 1188 AS3 Warning 1102 […]

  2. curtismorley.com » New Info added to AS3 Error 1067 says:

    […] It is highly related to AS3 Warning 1102 […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Highlight your code before posting code:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">