You can also check out Flex's NameUtil class (mx.utils.NameUtil I believe).
It basically does what Jason suggested but tracks a separate series of id's
per class name. Thus, you get get series such as Button1, Button2, Button3,
HList1, HList2, etc.
If you're talking about globally unique ID (or universally unique ID),
there's a function somewhere in the API (search IUUID or UUID in the docs)
that'll do a best attempt at generating an ID in AS based on the random
number generator and the clock (which is the practically the best you can do
without the Flash Player being able to provide something like a NIC serial
number or CPU ID).
Troy.
On 3/1/07, Jason King <[EMAIL PROTECTED]> wrote:
I'm not mr. actionscript but a class like this should facilitate what
you need.
class Idgen {
static var nextid:int = 0 ;
static function getNext:String() {
return "id" + nextid;
nextid++;
}
static function reset:void() {
nextid = 0;
}
}
Then call Idgen.getNext() to get a series of unique ids.
thetexaspsycho2003 wrote:
--- In [email protected], "thetexaspsycho2003"
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:
Is there a way to dynamically create an item's ID? For example pulling
it in from a XML file?
I guess from the lack of replies there is no way of doing this. If so,
this is very disappointing. The ability to create IDs on-the-fly is
very helpful in other technologies, such as AJAX.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links