# Get the Class type of an object

**URL:** <https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695>\
**Category:** flash\
**Created:** [June 9, 2008, 8:59am UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695 "2008-06-09T08:59:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)\
**Post date:** [June 9, 2008, 8:59am UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695/1 "2008-06-09T08:59:38Z")

</div>

Say I created an object like this:

var p = new BasketBall();

I want to access a certain property of p, such that it would return “BasketBall” or anytihng to indicate for me the class type. Is that possible?

Thanks

---

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [June 9, 2008, 10:53am UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695/2 "2008-06-09T10:53:40Z")

</div>

This is a total hack, but you could use this.

var p:MovieClip = new MovieClip();  
var pType:String = p.toString().substr(p.toString().indexOf(" ")+1);  
pType = pType.substr(0,pType.length-1);  
trace("hmm. "+ pType);

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [June 9, 2008, 12:12pm UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695/3 "2008-06-09T12:12:14Z")

</div>

[http://livedocs.adobe.com/flex/3/langref/flash/utils/package.html#getQualifiedClassName()](http://livedocs.adobe.com/flex/3/langref/flash/utils/package.html#getQualifiedClassName())

---

<div class="post-metadata">

**Author:** ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)\
**Post date:** [June 9, 2008, 12:12pm UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695/4 "2008-06-09T12:12:45Z")

</div>

Im sure there’s somethign much easier than that …

is this hack cuz there’s nothing else available?! Or just cuz it’s quick & dirty? There should be a way to access the type. I mean, when you trace the object, it tells you P: [object BasketBall] , so there must be a way to get “BasketBall”

Any ideas?

---

<div class="post-metadata">

**Author:** ![Ayman](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Ayman](https://forum.kirupa.com/u/Ayman)\
**Post date:** [June 9, 2008, 1:39pm UTC](https://forum.kirupa.com/t/get-the-class-type-of-an-object/262695/5 "2008-06-09T13:39:15Z")

</div>

Thanks Sephiroth!
