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

Create containers with library movieclip using for loop.

Explorer ,
Mar 07, 2018 Mar 07, 2018

Copy link to clipboard

Copied

Hello,
I can create multiple shape using for loop, like this:-
for (var j = 0; j < 15; j++) {

grid = new createjs.Shape();

grid.graphics.beginStroke("#252525").beginFill("white").drawRect(0, 0, 50, 50).endFill();

grid.set({

x: 100,

y: j * 50

})

stage.addChild(grid);           

};

But when I tried to create container with library movieclip, it is not working.
I googled but didn't find solution. here is the code I am using:-

btnForward = new lib.btnForward(); // reference from library linkage element

for(var i = 0; i < 10; i++){

    var buttonF = new createjs.Container();

    buttonF.cursor = "pointer";

    buttonF.x = 513;

    buttonF.y = 82 + (i * 40);

    buttonF.addChild(btnForward);

     stage.addChild(buttonF);

}

Thanks

Views

703

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

correct answers 1 Correct answer

Community Expert , Mar 08, 2018 Mar 08, 2018

Hi.

Try this:

for (var i = 0; i < 10; i++)

{

    var buttonF = new createjs.Container();

    var btnForward = new lib.btnForward();

    buttonF.cursor = "pointer";

    buttonF.x = 513;

    buttonF.y = 82 + (i * 40);

    this.addChild(buttonF);

    buttonF.addChild(btnForward);

}

Regards,

JC

Votes

Translate

Translate
Community Expert ,
Mar 08, 2018 Mar 08, 2018

Copy link to clipboard

Copied

Hi.

Try this:

for (var i = 0; i < 10; i++)

{

    var buttonF = new createjs.Container();

    var btnForward = new lib.btnForward();

    buttonF.cursor = "pointer";

    buttonF.x = 513;

    buttonF.y = 82 + (i * 40);

    this.addChild(buttonF);

    buttonF.addChild(btnForward);

}

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
Adobe Employee ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

LATEST

Yes, the main timeline on Canvas is not referred to as 'stage'. It's exportRoot or simply use this as described above.

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