Two of our users got this error in the AIR application we develop (we only
know that their flash player versions were WIN 12,0,0,38x1024 and MAC
11,7,700,225x1050):

Error #1034: Type Coercion failed: cannot convert "null" to
com[.etc.]JobExpenseTO.

The code which causes it (we don't have the exact line number):

//imported is an Array
imported.sortOn("lineItemOrder", Array.NUMERIC);

for(var i:int = 0; i < imported.length; i++) {
 var jobExpense:JobExpenseTO = imported[i];
 addLineSignal.dispatch(jobExpense);
}

The only way I could reproduce this exact error in code was to try to cast
the "null" String literal to the TO. But from careful inspection of our
code it's clear there is no way that a string can sneak its way into that
Array. So I imagine it must be a null value instead of a "null" String.

If that's the case, how is it possible to generate such an error? Just
casting from null won't do it (see below). Via Google I only found 3 places
where such an error has been reported:
[1]<https://groups.yahoo.com/neo/groups/flexcoders/conversations/topics/136709>,
[2]<https://groups.yahoo.com/neo/groups/flexcoders/conversations/topics/93564>,
and 
[3]<http://stackoverflow.com/questions/7028241/error-with-google-ima-sdk-for-flash>
.

In a test project tried to do things like

var arr:Array = [new Button(), new Button(), null];
var button:Button = Button(null);
for (var i:int = 0; i < arr.length; i++)
{
 button = Button(arr[i]);
button = arr[i] as Button;
}


...and like...

var arr:Array = [new Button(), new Button(), null];
arr.sortOn("left", Array.NUMERIC);

...and, just as expected, there's no error, and in the second example the
array items don't change into other types.

Any ideas?

Reply via email to