Automate Drawing Circles
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
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
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
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.