Get alpha data detection works on desktop, offsets in hype reflect


(Lucky) #1

Hey guys,
I created a script which picks up alpha data from any png you give it and when you drag the red square with the mouse on to it it does a hit test detection based off the alpha data on that specified pixel. It works great in desktop, but i can’t figure out why on the ipad in hype reflect it offsets and it still works but its always offset. I dont get which one of my items is messing up on ipad.
i get the document offset with
var docLeft=document.getElementById(hypeDocument.documentId()).offsetLeft;
i get the mouse position with
var mouseL=event.pageX-docLeft;
and all of these return the exact same value on ios(see all the output text boxes i have set up) and yet it offsets :confused: any suggestions on what’s causing this appreciated.

imagedata_v3.zip (101.0 KB)


#2

Are you seeing the correct behavior in Mobile Safari?

I think it is working correctly for me:

Can you clarify what numbers you’re expecting see in different situations and what you are seeing?


Hittest and cross-origin problem
(Lucky) #3

Hey yeah I solved this now,
the bounding boxes weren’t giving me correct dimensions so i changed them to parseInt(image1.style.left)
And now i have a hit test detector for image alpha :smile:
imagedata_v4.zip (94.9 KB)