Skip to main content
Participant
January 1, 2008
Question

addChild with variables?

  • January 1, 2008
  • 3 replies
  • 331 views
What I want to do here is create a function that I can use with many different movie clips. But I cannot for the life of me figure out how to addChild where the "child" is going to change. I've simplified my code to work this out before I go deeper. Again- I want to make a function that I can run on-- let's say-- 50 different movie cips. This is all written on the timeline. Help appreciated!

This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
January 3, 2008
you're welcome.
Inspiring
January 2, 2008
quote:

Originally posted by: ct119
But I cannot for the life of me figure out how to addChild where the "child" is going to change. ... Again- I want to make a function that I can run on-- let's say-- 50 different movie cips.


Hi. Using an array will give you the indirection that you want

e.g., addChild(myArray);

and myArray can point to any object that you want

ct119Author
Participant
January 2, 2008
Thanks! I haven't worked much with arrays at this point, but it is dawning on me that I need to! Thanks!
kglad
Community Expert
Community Expert
January 2, 2008
you'll probably want to pass a display object container (holder1) to sketch to be the parent of your line movieclip(s).

but you'll need to rethink your coding, too: that loop is going to add one copy of line with x and y properties equal to the next-to-last values of lineX and lineY.
ct119Author
Participant
January 2, 2008
Thanks! Yes- I caught that error. Too much cut and paste. Thanks for your help!