Monday, November 26, 2007

Little fix for the Flight Reservation sample app for Flex Builder 3

I used to work on http://www.qantas.com and thought this might be a cool little thing to check out. In fact we had some small talks about Adobe Flex when I was there.

Anyway, I downloaded this sample app and discovered a small bug that prevented me from giving it a whirl. The following error existed :


1067: Implicit coercion of a value of type int to an unrelated type Array


Here's the code :

private function formatDistance(km:Number):String
{
var distanceConversionFactor:Number =
resourceManager.getNumber(MY_BUNDLE, "DISTANCE_CONVERSION");

return resourceManager.getString(MY_BUNDLE, "DISTANCE_FORMAT",
int(km * distanceConversionFactor));
}


This is my change :

private function formatDistance(km:Number):String
{
var distanceConversionFactor:Number =
resourceManager.getNumber(MY_BUNDLE, "DISTANCE_CONVERSION");

var result:Number = km * distanceConversionFactor;
var parameters:Array = new Array();
parameters.push(result);

return resourceManager.getString(MY_BUNDLE, "DISTANCE_FORMAT", parameters);
}


Matt

0 comments: