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

anybody else notice this canvas/easeljs peculiarity?

Community Expert ,
Apr 05, 2024 Apr 05, 2024

Copy link to clipboard

Copied

it's not possible to reparent a symbol created with drawing tools and added from the library or created on-stage (draw whatever > convert to symbol) unless it's removed (and that's not doable via removeChild) first from the stage.  ie,

 

this.box.addChild(this.circle); 

/* won't work with on-stage instances of this.box and this.circle without prior removal of this.circle*/

 

 

 

Views

3.6K

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 2 Correct answers

Community Expert , Apr 06, 2024 Apr 06, 2024

Probably because of stage's life cycle.

 

Something like this should work.

stage.on("drawend", function(){ this.box.addChild(this.yourContainer.circle); }, this, true);

Votes

Translate

Translate
Community Expert , Apr 06, 2024 Apr 06, 2024

What does happen if you call stop on this.box2 first?

Votes

Translate

Translate
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

Hi, k.

 

You need to call this.stop() even if the timeline has only one frame - because it seems it continues playing - for display list's methods to work properly.

 

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

ohhh, that sounds promising.  testing.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

that was it.  thank you, thank you, thank you, thank you.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

i spoke too soon.  it worked in the case of main timeline object added to another object.

 

but failed silently when trying to reparent a non-main timeline object.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

Probably because of stage's life cycle.

 

Something like this should work.

stage.on("drawend", function(){ this.box.addChild(this.yourContainer.circle); }, this, true);

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

the event fires but, that fails to reparent, too.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

Make sure you're also stopping the target's instance timeline.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

still doing that:

 

this.stop();
 
this.box1.addChild(this.cc);  // works wth cc instance on main stage
 
// box mc instances of box which has child cc
this.box1.rotation = 45;
this.box2.rotation -= 22.5;
stage.on("drawend", function(){console.log("H"); this.box1.addChild(this.box2.cc); }, this, true);  // fails
//stage.on("drawend", reparentF.bind(this));  // fails
 
stage.update();
 
function reparentF(){ 
this.box1.addChild(this.box2.cc);
}

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

What does happen if you call stop on this.box2 first?

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

ooh, excited to test stopping all.

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
Community Expert ,
Apr 06, 2024 Apr 06, 2024

Copy link to clipboard

Copied

ok, you got it.  there are two things i was missing:

 

1. the object to be reparented:  its parent timeline must be stopped before it can be reparented

2. the event "drawend" (or some other delay) must be implemented.

 

the reparenting is momentarily visible unless stage.update() is executed after the addChild code.

 

this.sq2.stop();
stage.on("drawend", reparentF.bind(this));
 
function reparentF(){ 
this.sq1.addChild(this.sq2.cc3);
stage.update();  // if this is executed in listener function, before the addChild(), an infinite loop is triggered
}

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
Participant ,
Apr 17, 2024 Apr 17, 2024

Copy link to clipboard

Copied

LATEST

If you enable the _off property it will remove a child from the list of managed children. If animated you will also need to remove any tweens that target it from the timeline if such tween sets a state or _off property.

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