My friends and family are under attack in Ukraine. Donate to protect them directly or help international organizations.

Flex Randomness

January 13th, 2009

The only reason why your Flex app should do something randomly is by your using the Math.random() function. You can argue about the UIDUtil.createUID() and such but you get the point. Today I witnessed randomness as never before.

Try to run this code (Flex 3.2)

var obj:Object = { a: "valueA", b: "valueB" };
for(var property:String in obj) {
  trace(property);
}

Sometimes it will output a-b and other times b-a. I have no idea how it determines the order and how come it's never the same. But it sure caused me some pain. Found a workaround using PHP once received on the back-end!

Previous: if (value is Object) problem Next: lastIndexOf with RegEx?