• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Accessing movieclip children

Community Beginner ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

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.

Views

97

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 23, 2021 Apr 23, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines