[FlashCodersNY] AS3 identify class name from object

Alan Shaw alan at nodename.com
Tue Dec 11 22:41:03 PST 2007


  A bit more generally:  to get the class name of an object, you could try
this:

  import flash.utils.*;

    public function getClassName(o:Object):String
    {
        var fullClassName:String = getQualifiedClassName(o);
        return fullClassName.slice(fullClassName.lastIndexOf("::") + 2);
    }

I use this all the time, as well as a getClass() function that returns the
object's Class.

-A


On 12/11/07, eric socolofsky <eric at transmote.com> wrote:
>
> typeof() is, i believe, deprecated in AS3.  you should use the 'is'
> operator.
> if (someArray is Array) {
> //do stuff
> }
>
> -eric
>
> On Dec 11, 2007, at 7:00 PM, flashcodersny-request at flashcodersny.orgwrote:
>
> Message: 6
>
> Date: Tue, 11 Dec 2007 18:59:59 -0500
>
> From: Ivan Safrin <ivansafrin at gmail.com>
>
> Subject: [FlashCodersNY] AS3 identify class name from object
>
> To: "This is the general mailing list for FlashCodersNY.org"
>
> <flashcodersny at flashcodersny.org>
>
> Message-ID: <2165EEB1-F819-4315-829B-607DD2AAD88B at gmail.com>
>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> Hello,
>
>
> I'm wondering if it's possible to identify an ambiguous "pointer" in
>
> AS3 as the class that it actually is. Basically, I'm trying to
>
> distinguish whether something is an array or an object, and AS3 treats
>
> arrays as a regular class, ie. typeof() returns "object" on an array,
>
> just the same as an object. Just seeing if anyone's tried doing
>
> something similar. Thank you!
>
>
>
> _______________________________________________
> FlashCodersNY mailing list
> FlashCodersNY at flashcodersny.org
>
> http://mail.flashcodersny.org/mailman/listinfo/flashcodersny_flashcodersny.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.flashcodersny.org/pipermail/flashcodersny_flashcodersny.org/attachments/20071212/71d99f82/attachment.html 


More information about the FlashCodersNY mailing list