Skip to main content
Known Participant
April 23, 2021
Question

Accessing movieclip children

  • April 23, 2021
  • 1 reply
  • 181 views

Seems like a simple issue, but I haven't been able to figure it out.

var clip1 = new lib.Firstclip();

this.addChild(clip1); 

function childAdder(){
	var clip2 = new lib.Secondclip();

	clip1.addChild(clip2);
}

childAdder();

console.log(clip1); // returns >lib.Firstclip

console.log(clip1.children[1]); // returns >lib.Secondclip

console.log(clip1.clip2); // returns undefined

How do I access clip2?  I tried using a timer delay, and putting code on the second frame, but I get the same results, and I'd prefer not to have to do either of those things anyway.

    This topic has been closed for replies.

    1 reply

    Long ConAuthor
    Known Participant
    April 23, 2021

    Okay, when I posted that, I found a thread I hadn't seen yet in my searches, and I think my issue is solved by using clip1.getChildByName("clip2").  

     

    I could delete the thread, but I wouldn't mind an expert angle on the situation.  Maybe there's a better way to do it, or some understanding I should have.