JavaScript Date objects passed through the Adobe AIR SandboxBridge lose their type

Issue: Objects passed through the AIR SandboxBridge lose their type

If you attempt to pass a JavaScript Date through the Adobe AIR SandboxBridge, it loses its type and appears only as Object.

Solution: Send the date in milliseconds from a known base time

The example code below demonstrates how you can serialize and deserialize the date so that its object type is maintained.

// Sending the number of milliseconds since 1 January 1970 00:00:00
myDate = new Date("January 1, 2008");
dateLong = myDate.getTime();

// ~~~ Bridge ~~~

mySameDate = new Date();
mySameDate.setTime(dateLong);

Additional information

Prototype methods of objects are not serialized across the interface; only the object's properties are sent.

Get help faster and easier

New user?