Actionscript 3 GUID – Generating unique IDs for users in AS3
Have you ever needed to generate a unique ID for users? I’m sure you have. But, have you ever had to create a unique ID for users without referencing the other user IDs (checking for duplicates)? I ran into this issue and discovered globally unique identifier (GUID for short). This is something constantly used in the programming world, but not something I needed in the actionscript world, until now. Being a Flash developer who comes from a design background, I am constantly catching up with the tips and tricks of the hard core programming community.
To give you a little background on a GUID, it is a reference number that is randomly generated. The beauty of a GUID is that the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is infinitesimally small.
Since this instantly became something I could use in future projects, I decided to create an actionscript 3 class. I used the AS2 class created by Meychi.com (which is no longer up for some reason) as a base for the GUID equation.
To make sure my fellow Flash developers have the tools they need to create GUIDs, I have uploaded this file for download.
You can use this class by calling the “GUID.create()” function.
Thanks for the class.
Thanks a lot. You saved me couple of hours of work!
Good job, buy this is a utility class and you shouldn’t be extending Sprite as a base class unless you are implying a GUID is a sprite. Only trying to help.
Just a note if you are using flex you can simply use UIDUtil:
import mx.utils.UIDUtil;
UIDUtil.createUID();
Very nice work man. This was really helpful.
awesome bro thanks!
Thanks man ! it’s very helpful
Just saved me a couple of hours. Thx for sharing
Thanks! I was used to Flex which had it built in and couldn’t find the Flash equivalent. Your class fits the bill! Well done!
You bad-ass, thanks for sharing this!
Legend!!!