Create A CF Style UUID In Flex
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:
private function createUUID():String{
var uuid:String = UIDUtil.createUID();
var uReturn:String;
uReturn = uuid.substr(0,23);
uReturn += uuid.substr(24,uuid.length);
return uReturn;
}
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.






There are no comments for this entry.
[Add Comment]