Highlighted

How can I addchild to a layer rather than the stage?

New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Im creating an animation where the user can click to add elements to the screen but the issue is whenever the user clicks the element is stuck relative to the stage not the background (the element moves with the stage) and Im not sure how to fix this

 

function fl_MouseClickHandler_4()
{
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
var fl_MyInstance_4 = new lib.Cloud1();

this.addChild(fl_MyInstance_4);
fl_MyInstance_4.y = stage.mouseY;
fl_MyInstance_4.x = stage.mouseX;

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

So don't add them to the stage. Create a container movieclip and add them to that instead.

TOPICS
Code

Views

31

Likes

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

How can I addchild to a layer rather than the stage?

New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

Im creating an animation where the user can click to add elements to the screen but the issue is whenever the user clicks the element is stuck relative to the stage not the background (the element moves with the stage) and Im not sure how to fix this

 

function fl_MouseClickHandler_4()
{
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
var fl_MyInstance_4 = new lib.Cloud1();

this.addChild(fl_MyInstance_4);
fl_MyInstance_4.y = stage.mouseY;
fl_MyInstance_4.x = stage.mouseX;

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

So don't add them to the stage. Create a container movieclip and add them to that instead.

TOPICS
Code

Views

32

Likes

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
Aug 03, 2020 0
Adobe Community Professional ,
Aug 03, 2020

Copy link to clipboard

Copied

So don't add them to the stage. Create a container movieclip and add them to that instead.

Likes

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
Reply
Loading...
Aug 03, 2020 1
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

how would I go about doing this ? I've never done this before thanks

Likes

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
Reply
Loading...
Aug 03, 2020 0
New Here ,
Aug 03, 2020

Copy link to clipboard

Copied

thanks I got it working 

Likes

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
Reply
Loading...
Aug 03, 2020 0