Home Tutorials Forums Articles Blogs Movies Library Employment Press

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

Thread Tools Rate Thread Display Modes
Old 09-23-2008, 08:46 PM   #1
Registered User
Join Date: Sep 2008
Posts: 9
Default iterate through "this" properties

i can do

	var test:Object = {
	for (var prop:String in test){;
but i can't do

public function init(){
	var me = this;
	for (var prop:String in me){
is there no way to iterate through the global "this", so that i can target/select multiple elements without actually needing to know their ids?
chrismarx is offline   Reply With Quote
Old 09-23-2008, 08:56 PM   #2
Super Moderator
xxneon's Avatar
Join Date: Dec 2006
Location: Amish Country, PA
Posts: 8,570
Send a message via ICQ to xxneon Send a message via AIM to xxneon Send a message via MSN to xxneon Send a message via Skype™ to xxneon

when you iterate 'this' it will not iterate the same way as it did with as2.. iterating though properties of this will only show you any dynamic properties that were added to 'this' it will not show every property associated to 'this'..

and to iterate though children on the display list of a container .. i would think that you would need to iterate based on the children length..

ActionScript Code:
var totalChildren:int = this.numChildren; var item:int; for(item = 0; item < totalChildren; item++){     trace(this.getChildAt(item).name); }

there might be a better way .. but this would at least iterate through the children of 'this' based on what is on its display list.
Always optimizing...
xxneon is offline   Reply With Quote
Old 09-23-2008, 08:57 PM   #3
six eyes
senocular's Avatar
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular

for..in loops only iterate through dynamic properties (of dynamic classes). If you want to iterate through non-dynamic properties, use describeType.
senocular is offline   Reply With Quote
Old 09-24-2008, 05:31 PM   #4
Registered User
Join Date: Sep 2008
Posts: 9

thanks for both replies, very useful! i noticed that it appears that elements don't show up in "this" unless they've been assigned id's. So am i correct in assuming that if i want to, for instance, find all the label elements in my mxml, that i would need to traverse all the parent elements, since they're not directly exposed? I'm attempting an alternative approach by building a custom label component with the logic i need, but I'm having some trouble there as well, check out the post-

chrismarx is offline   Reply With Quote

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
for..in loop to get class properties Aiwa ActionScript 3.0 6 04-30-2008 12:52 AM
custom document properties ryryguy Flash 9 General Questions 0 08-30-2007 06:33 PM
get textfield properties m.i.c. ActionScript 2.0 2 05-31-2007 07:51 AM
Wierd Timeline Transition Error Benaiah Other Flash General Questions 1 08-01-2006 04:32 PM
cannot set/get properties on class instance - why? kracko ActionScript 2.0 10 08-07-2005 08:26 PM

All times are GMT. The time now is 09:55 AM.

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.