Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 17:25
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  Nested Display Object Containers + display list
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Nested Display Object Containers + display list  (Read 980 times)
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« on: 04/09/10, 13:05 »

Hey there-  Quick question regarding the display list in as3.  Let's say I have a container and I add 3 children.  With each of the children I add another child.  Like so:

container
  - child1
      - childA
  - child2
      - childA
  - child3
      - childA

How might I access the "childA" objects?  Because the below is not working:
Code:
container.getChildAt(container.getChildIndex(container.getChildAt(0)));

Any help is appreciated!  Thanks!
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 04/09/10, 13:44 »

Something like this (supposing all are MC, if not cast properly):


var holder:MovieClip =  container.getChildAt(0)
var target:MovieClip = holder.getChildAt(0)

Or

container.getChildAt(0).getChildAt(0);


Jorge
Logged

worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« Reply #2 on: 04/09/10, 14:02 »

Excellent thanks for responding Jorge!

As mentioned above I had to do some casting to get it to work.  Here's some relavent code for future on lookers:

Code:
trace((MovieClip(container.getChildAt(0)).getChildAt(0) as MovieClip).name);
Code:
var holder:MovieClip = container.getChildAt(0) as MovieClip;
var target:MovieClip = holder.getChildAt(0) as MovieClip;

trace(target.name);
[code]
[/code]
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!