Skip to main content
Inspiring
February 20, 2022
Answered

HTML5 Canvas - Nested button to move parent

  • February 20, 2022
  • 2 replies
  • 282 views

I have a graphic symbol which contains a nested button.  When clicked, I want that button to move the parent graphic symbol to a location X Y.

 

This is not working, though the nested button gets it's pointer cursor.

 

this.closeLens.addEventListener("click", closeThisLens.bind(this));

function closeThisLens()
{
	this.parent.x = -200;
	this.parent.y = -850;
}
    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Is the code located inside of the Graphic symbol? Because actions don't run on the timelines of Graphic symbols. You need to convert your Graphic to Movie Clip and replace this.parent in the code by this only because you want to move the Graphic instance itself and not its parent.

     

    Regards,

    JC

    2 replies

    FlatChatAuthor
    Inspiring
    February 21, 2022

    Thanks JC, that did the trick!

     

    Peter

    JoãoCésar17023019
    Community Expert
    Community Expert
    February 21, 2022

    Awesome!

     

    You're welcome!

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    February 20, 2022

    Hi.

     

    Is the code located inside of the Graphic symbol? Because actions don't run on the timelines of Graphic symbols. You need to convert your Graphic to Movie Clip and replace this.parent in the code by this only because you want to move the Graphic instance itself and not its parent.

     

    Regards,

    JC