1

I'm using BlazeDS to marshall Java objects to Flex. What I'm seeing is that if a Java Float holds a integer value (whole number, such as 123), then it gets marshalled to a ActionScript int. I would expect that a Java Float always gets marshalled to an ActionScript Number as documented in the BlazeDS Developer Guide.

Is there a way to configure this or is this just a BlazeDS bug?

Follow-up: The float is contained within a map. The Java map that is being passed to BlazeDS looks something like:

Map map = new HashMap();
Float f = 123.0;
map.put("number", f);

When it arrives on the Flex side map is an Object:

var map:Object = ...
trace(map.number);
trace(getQualifiedClassName(map.number));

prints:

123
int

So it's serializing the value correctly, just as the wrong type.

Steve Kuo
  • 61,876
  • 75
  • 195
  • 257

2 Answers2

2

This has nothing to do with BlazeDS itself. It's a AS3 "feature"..

This will help understanding what's going on. Or confuse you even more...

First thing: **JAVA: java.lang.Float and float ==> AS3: Number **

var number:Number = 4.5;
trace(typeof(number) == "number");      //true
trace(number is Number);                //true

var integer:int = 2;
trace(typeof(integer) == "number");     //true!
trace(integer is Number);               //true!

//number=4.5
trace(number is int);                   //false
trace(getQualifiedClassName(number));   //Number

//Here comes the fun..
number=number-0.5; //number=4
trace(number is int);                   //true!!
trace(getQualifiedClassName(number));   //int!!

Hope this actually helped!

Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
0

Are the variable names same in AS3/Java value objects?

In the value object , that has RemoteClass tag, AS3

public var myfloat:Number;

Java

public float myfloat = 10.4f;

For precision info: Look at this post: How to deal with Number precision in Actionscript?

Community
  • 1
  • 1
Satish
  • 6,457
  • 8
  • 43
  • 63