OBSOLETE TECHNOLOGY

Adobe Flash and ActionScript reached end-of-life on December 31, 2020.
This code is preserved for historical reference only. For modern web development, please use JavaScript instead.

ActionScript3 (OBSOLETE)

Below is code to generate GUIDs in ActionScript3. This is just a random implementation and there is no claim that they are true UUIDs. They just look like UUIDs.

function create( value:Array = null ):String {

	var uid:Array = new Array();
	var chars:Array = new Array( 48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70 );
	var separator:uint = 45;
	var template:Array = value || new Array( 8,4,4,4,12 );

	for ( var a:uint = 0; a < template.length; a++ ) {
		for ( var b:uint = 0; b < template[a]; b++ ) {
			uid.push( chars[ Math.floor( Math.random() *  chars. length ) ] );
		} if ( a < template.length - 1 ) {
			uid.push( separator );
		}
	}

	return String.fromCharCode.apply( null, uid );
}

source from CodeSnippets (archived)

Migration Path: If you're modernizing a Flash application, consider using JavaScript with crypto.randomUUID() for web applications, or the appropriate native API for your target platform.