Object Comparison In Flex/AIR

3 views
Skip to first unread message

vrathore

unread,
Jun 7, 2008, 1:12:49 AM6/7/08
to Delhi Flex User Group
Object Comparison In Flex/AIR

To compare the objects whether they are same or not we can use
following method of SerializeUtil Class

public class SerializeUtil
{
public static function ObjectToString(object: *): String
{
var ba: ByteArray = new ByteArray();
ba.writeObject(object);
return ba.toString();
}
public static function ObjectToByteArray(object: *): ByteArray
{
var ba: ByteArray = new ByteArray();
ba.writeObject(object);
ba.position = 0;
return ba;
}
}


To do the actual comparison just use these lines of code to compare
the two objects.

if
(SerializeUtil.ObjectToString(object1)==SerializeUtil.ObjectToString(object2))
{
// Objects are 'equal'
}
else
{
// Objects are not 'equal'
}

Thanks and Regards

Varun Rathore
Reply all
Reply to author
Forward
0 new messages