Highlighted

Mouse Events Not Working for PNGs in MovieClips - Works for Vector Shapes

Explorer ,
Dec 19, 2019

Copy link to clipboard

Copied

When I use the code below for a vector shape in a MovieClip, it works, but when I do the same exact thing where a png is used instead of a shape, nothing happens and the JavaScript breaks down. How can I do the same thing with pngs that I am able to do with vector shapes created in Animate? Thanks.

this.pngMe.on("pressmove", function(event) {
    var p = this.globalToLocal(stage.mouseX, stage.mouseY);
    this.pngMe.x = p.x;
    this.pngMe.y = p.y;	
}, this);

 

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

You know how Animate likes to spam this message in the Output window when you test an HTML5 Canvas document?

Content with both Bitmaps and Buttons may generate local security errors in some browsers if run from the local file system.

A bitmap with a mouse event handler is basically a button. So... yeah.

TOPICS
Code, How to, Performance

Views

365

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

Mouse Events Not Working for PNGs in MovieClips - Works for Vector Shapes

Explorer ,
Dec 19, 2019

Copy link to clipboard

Copied

When I use the code below for a vector shape in a MovieClip, it works, but when I do the same exact thing where a png is used instead of a shape, nothing happens and the JavaScript breaks down. How can I do the same thing with pngs that I am able to do with vector shapes created in Animate? Thanks.

this.pngMe.on("pressmove", function(event) {
    var p = this.globalToLocal(stage.mouseX, stage.mouseY);
    this.pngMe.x = p.x;
    this.pngMe.y = p.y;	
}, this);

 

Adobe Community Professional
Correct answer by ClayUUID | Adobe Community Professional

You know how Animate likes to spam this message in the Output window when you test an HTML5 Canvas document?

Content with both Bitmaps and Buttons may generate local security errors in some browsers if run from the local file system.

A bitmap with a mouse event handler is basically a button. So... yeah.

TOPICS
Code, How to, Performance

Views

366

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
Dec 19, 2019 0
Explorer ,
Dec 19, 2019

Copy link to clipboard

Copied

HI,
its works vector space or png inside of Movieclip

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...
Dec 19, 2019 0
Explorer ,
Dec 20, 2019

Copy link to clipboard

Copied

It didn't work for me when I replaced a vector shape with a png inside a MovieClip.

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...
Dec 20, 2019 0
Adobe Community Professional ,
Dec 20, 2019

Copy link to clipboard

Copied

I just tried it, and it worked perfectly when I replaced a vector shape with a PNG inside a movieclip. Tested in both Animate 18 and 20.

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...
Dec 20, 2019 0
Explorer ,
Dec 26, 2019

Copy link to clipboard

Copied

Is there a way I can access your file? I can't figure out why mine is not working. I publish it and then try it in Chrome, but it fails to work.

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...
Dec 26, 2019 0
Adobe Community Professional ,
Dec 26, 2019

Copy link to clipboard

Copied

Does it work when you test it from within Animate?

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...
Dec 26, 2019 0
Explorer ,
Dec 26, 2019

Copy link to clipboard

Copied

Just now I went to Control > Test, and it worked. The Test Movie has In Browser checked, so I didn't even need to test it in Animate. I guess the problem has to do with how it's being published, because that's when it doesn't work.

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...
Dec 26, 2019 0
Adobe Community Professional ,
Dec 26, 2019

Copy link to clipboard

Copied

You know how Animate likes to spam this message in the Output window when you test an HTML5 Canvas document?

Content with both Bitmaps and Buttons may generate local security errors in some browsers if run from the local file system.

A bitmap with a mouse event handler is basically a button. So... yeah.

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...
Dec 26, 2019 0
Explorer ,
Dec 26, 2019

Copy link to clipboard

Copied

I have not seen this error before, but if that's the case, then I will need to only test until I upload my published work onto a server, or use another browser. I just tried my published work on Microsoft Edge and it works. Thanks for your help.

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...
Dec 26, 2019 0