Highlighted

Pin child image roatation and translation

Explorer ,
Jan 09, 2019

Copy link to clipboard

Copied

Hello community,
I am working on a project that have a protractor image and a rotation-handle image for the protractor.

The rotation-handle rotates the protractor.

rotationHandle.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

rotationHandle.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

     protractor.rotation = rotationHandle.rotation = Math.atan2(protractor.y - this.y, protractor.x - this.x) * 180 / Math.PI;

});

The issue is that when I move  the protractor, I need to move the rotation-image too.

protractor.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

protractor.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

});

can anybody please tell me how to achieve that.
Thanks.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

assign its offeset in mousedown and its x and y in pressmove.

Views

58

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

Pin child image roatation and translation

Explorer ,
Jan 09, 2019

Copy link to clipboard

Copied

Hello community,
I am working on a project that have a protractor image and a rotation-handle image for the protractor.

The rotation-handle rotates the protractor.

rotationHandle.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

rotationHandle.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

     protractor.rotation = rotationHandle.rotation = Math.atan2(protractor.y - this.y, protractor.x - this.x) * 180 / Math.PI;

});

The issue is that when I move  the protractor, I need to move the rotation-image too.

protractor.on("mousedown", function (evt) {

     this.parent.addChild(this);

     this.offset = {

          x: this.x - evt.stageX,

          y: this.y - evt.stageY

     };

});

protractor.on("pressmove", function (evt) {

     this.x = evt.stageX + this.offset.x;

     this.y = evt.stageY + this.offset.y;

});

can anybody please tell me how to achieve that.
Thanks.

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

assign its offeset in mousedown and its x and y in pressmove.

Views

59

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
Jan 09, 2019 0
Adobe Community Professional ,
Jan 10, 2019

Copy link to clipboard

Copied

assign its offeset in mousedown and its x and y in pressmove.

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...
Jan 10, 2019 0