Hi, Libby.

In general, an instance of an AS3 class doesn't have a name. Perhaps you
are thinking that the name of a variable containing a reference to an
instance is actually the name of the instance? That would be a
misconception, because there can be any number of variables referencing
the same instance. For example, if you do

    var a = new MyClass();
    var b = a;

then both the variable named 'a' and the one named 'b' reference the
same instance of MyClass. Neither should be considered an instance name
since the instance itself doesn't know about either of them; an instance
doesn't keep track of where references to it are stored.

I said "in general" in the first paragraph because some classes, such as
DisplayObject, actually have an instance property called 'name'. But I
don't think that's what you were talking about. In the case of
DisplayObject instances, Flex sets the 'name' property and you shouldn't
muck with it; in particular, Flex expects this name to be unique, so you
shouldn't try to make two instances of DisplayObject have the same name.

- Gordon


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Libby
Sent: Wednesday, December 28, 2005 4:35 PM
To: [email protected]
Subject: [flexcoders] Is there a way to find out the instance name of an
anonymous object?

I have reading the doco for AS2lib / reflection and have found how I
can get the class name. With the class name I can create a new
Instance. I would like to get the instance name of the original object
so that I can assign it to the new instance. Something like this:

// this is pseudocode
var s = existingObject.getName();
var x = class.forName(s).newInstance(); 
existingObject = instanceNameIfIJustKnewIt(x);

Any suggestions would be great.

Thanks,
Libby






--
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



 




--
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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to