Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-23-2012, 03:07 PM   #1
zeritor
Registered User
 
Join Date: Feb 2012
Posts: 7
Default How can I find the class of an extended MovieClip when probing the stage?

All my custom classes that extend MovieClip simply trace as "MovieClip" when using stage.getChildIndex(i); I'm trying to search the stage to see what objects have been placed and then add them to the correct array. E.g. if I place 5 "Enemies" on the screen, I want to then add them to an array by searching the stage for the "Enemies" class, without naming each one and adding it manually in the code.

Edit:
Code:
for(var i:int = 0; i < stage.numChildren-1; i++)
{
	trace(getQualifiedClassName(stage.getChildAt(i)));
}
Outputs this multiple times:
flash.display::MovieClip

Last edited by zeritor; 02-23-2012 at 05:51 PM.
zeritor is offline   Reply With Quote
Old 02-23-2012, 03:26 PM   #2
SephirothOWA
Senior Member
 
Join Date: Jun 2010
Location: Ipswich, England
Posts: 255
Default

you might want to look at flash.utils.getQualifiedClassName mate
SephirothOWA is offline   Reply With Quote
Old 02-23-2012, 03:40 PM   #3
zeritor
Registered User
 
Join Date: Feb 2012
Posts: 7
Default

I tried using that and it still tells me MovieClip :S

I know it's it's own class because it has all the correct properties set if I do reference it by a name.
zeritor is offline   Reply With Quote
Old 02-24-2012, 12:08 PM   #4
zeritor
Registered User
 
Join Date: Feb 2012
Posts: 7
Default

Is it possible to search through objects stored in the memory? All I need is a reference to the item on the stage without calling it's instance name directly (ideally I'd want to be able to access them without setting a name).
zeritor is offline   Reply With Quote
Old 02-24-2012, 02:34 PM   #5
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,679
Send a message via Skype™ to henke37
Default

You are checking the wrong display list. The stage is not the main timeline.

And please, use the "is" operator, no string comparisons. It is better looking and doesn't fail at the empty subclass test.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is online now   Reply With Quote
Old 02-24-2012, 04:03 PM   #6
zeritor
Registered User
 
Join Date: Feb 2012
Posts: 7
Default

I use the is operator, I just can't find the elements to check against. What should I search instead, henke37?
zeritor is offline   Reply With Quote
Old 02-24-2012, 11:53 PM   #7
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,679
Send a message via Skype™ to henke37
Default

Well, that greatly depends on the structure of your display tree. You need to be able to draw your own tree on a piece of paper. The root node is always the stage and the only child is the main timeline. Work from there and it should be obvious what you need to do to get from the object you are in to the object you want to iterate on.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is online now   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:11 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.