Skip to main content
Inspiring
Feb 20, 2022 9:07 AM UTC
Answered

HTML5 Canvas - Nested button to move parent

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 is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Feb 20, 2022 2:43 PM UTC

    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

    3 replies

    FlatChatAuthor
    Inspiring
    Feb 21, 2022 12:23 AM UTC

    Thanks JC, that did the trick!

     

    Peter

    Translate
    JoãoCésar17023019
    Community Expert
    Community Expert
    Feb 21, 2022 8:18 PM UTC

    Awesome!

     

    You're welcome!

    Translate
    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Feb 20, 2022 2:43 PM UTC

    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

    Translate