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

add child from lib

Explorer ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

i used the code to add moviclip from library --> it is work

root["emp"].addChild(new lib.pic1());

 

what is the new intance name?

 

i tried to change the color but it is not reconize the movie clip name.

for(i=1;i<63; i++)
{
root["emp"]["pic1"]["p"+i].shape.graphics._fill.style =color;
}

Views

129

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 Expert ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

Hi.

 

Can you provide the full relevant code so we can understand better what's going on?

 

Regards,

JC

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
Explorer ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

i want to do a color book

i load from the library the picture (pic1)

 

root=this;
var color= "#ffffff";


this["emp"].addChild(new lib.pic1());

function clean_pic()
{
for(i=1;i<63; i++)
{
root["emp"]["pic1"]["p"+i].shape.graphics._fill.style =color;
}
}

clean_pic();

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
LEGEND ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

Dynamically instantiated movieclips doesn't have a directly accessible instance name unless you create one. You create one by assigning the reference to the movieclip to a property on its parent timeline (or anywhere really, but the parent timeline is most intuitive). E.g.--

 

var newPic = new lib.pic1();

root.emp.addChild(newPic);

root.emp.p37 = newPic;

 

By the way, the entire point of bracket notation is to perform variable interpolation. For pure string literals it's pointless and you should just use dot notation. Like this:

 

root.emp["p" + 1).bla bla bla

 

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
Explorer ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

LATEST

thank you it is worek

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