Skip to main content
charlesn79540358
Inspiring
January 3, 2019
Answered

Automate Drawing Circles

  • January 3, 2019
  • 1 reply
  • 4025 views

Hello,

I know you can't convert actionscript actions to javascript. But can you automate drawing circles on a parts diagram? So you don't have to manually create 50 circles.

Thank you

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    I am trying to add on to your code if you hover over the button it changes the background color to a orange color and a tool tip pops up that has the button number in it.


    Hi.

    Here's one suggestion.

    JavaScript code:

    // advanced layers off

    // export document as texture is off

    // tested in Animate CC 2019 (version 19.1, build 349)

    var hoverColor = "#E59A18";

    var that = this;

    var captionText = this.dtext;

    var tip;

    var parts =

    {

        hot1_btn:"Description 1",

        hot1b_btn:"Description 1b",

        hot2_btn:"Description 2",

        hot2b_btn:"Description 2b",

        hot3_btn:"Description 3",

        hot4_btn:"Description 4",

        hot5_btn:"Description 5",

        hot6_btn:"Description 6",

        hot7_btn:"Description 7",

        hot8_btn:"Description 8",

        hot9_btn:"Description 9",

        hot10_btn:"Description 10",

        hot11_btn:"Description 11",

        hot12_btn:"Description 12"

    };

    function start()

    {

        stage.enableMouseOver();

        tip = new lib.Tip();

        that.children.forEach(function(child)

        {

              if (parts[child.name])

              {

                  child.startColor = child.shape.graphics._fill.style;

                  child.on("click", function(e)

                  {

                        captionText.text = parts[child.name];

                  });

                  child.on("mouseover", function(e)

                  {

                        child.shape.graphics._fill.style = hoverColor;

                        tip.x = e.currentTarget.x;

                        tip.y = e.currentTarget.y - tip.nominalBounds.height * 0.5;

                        tip.txt.text = e.currentTarget.name.replace("hot", "").replace("_btn", "");

                        that.addChild(tip);

                  });

                  child.on("mouseout", function(e)

                  {

                        child.shape.graphics._fill.style = child.startColor;

                        that.removeChild(tip);

                  });

              }

        });

    }

    stage.on("drawstart", start, null, true);

    FLA download:

    animate_cc_html5_canvas_many_circles_02.zip - Google Drive

    I hope this helps.

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 3, 2019

    Hi.

    Can you provide more details?

    Regards,

    JC

    charlesn79540358
    Inspiring
    January 4, 2019

    Hello,

    Here is a small example. So we get these diagrams created with circles on them and we have to convert it to a flash file with using actionscript so the user can click on the circle and it will highlight them in a orange color and put the matching part number to the top of the list.

    Since Flash is going away I found Adobe Animate can convert it to a HTML5/Canvas but we have to create all the buttons and the action clicks still. I found the duplicate button feature in Adobe Animate but most of our diagrams have 50 circles or more. Just trying to find a fast solution.

    Thank you,

    Charles

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 4, 2019

    Hi.

    Thanks for the example.

    But I'll have to apologize because I'm still not getting...

    Do you have it all setup in Animate for an AS3 document but now you want the same interactivity in a HTML5 canvas document, right?

    But what is the issue you want to solve? You need a code to add the buttons at runtime for you, to add interactivity to them, to design/build them...?