Create A CF Style UUID In Flex
Posted By : todd sharp Posted At : November 19, 2008 4:52 PM Posted In: Flex, ActionScript
1
Wow, it feels kinda weird to actually blog something technical here. While working on a little Flex project recently I found myself with the need to create a CF style UUID (xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx) within Flex . Flex UID's follow the 8-4-4-4-12 pattern (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). Quite a simple task really when you think about it, but here is what I came up with:
var uuid:String = UIDUtil.createUID();
var uReturn:String;
uReturn = uuid.substr(0,23);
uReturn += uuid.substr(24,uuid.length);
return uReturn;
}
I could have gotten fancy and done it with a regular expression, but I'm sure the cost of manipulating the string in ActionScript isn't all too much to worry about.


