Hello
Hello

Reputation: 2265

How to get the parent childs(flash)

I am using adobe flash cs5, so

mainTimeline -> {

 child1 movieclip ->{

  //i want from here to get parent.child2, but i get an error that there are no child2

 }

 child2 movieclip ->{

 }

}

i've added a name to the child2 movieclip and exported it to actionscript, also i've tried stage.child2 - but he don't see it, i don't know what can be the reason..

Upvotes: 0

Views: 45

Answers (1)

mitim
mitim

Reputation: 3201

If the child movieclips are 'beside each other' on the timeline, how about trying:

child1.parent.child2

or maybe

(child1.parent).child2

The logic behind that is that child1.parent, should be a reference to the timeline, which then can access child2.

Though, if you are needing to do this a lot, it might be worth it to pass in a reference of child2 in to child1 or restructure your code to avoid this. There would be less 'blind dependencies' or 'searching via the timeline' that way and possibly less prone to breakage. It may also be more legible in the future to edit.

Upvotes: 1

Related Questions