[SOLVED] How to discover which instance was mouseover/clicked/touched in javascript?

  • I have a single object, called ‘betpads’
  • I have 160+ instances of it on the screen.
  • Each instance has a variable attached to it, called “betpos”

When putting a javascript block inside a “cursor/touch is on ‘betpads’” event (or any other event for that matter), how do i determine which instance was interacted with ?

Since each instance has a unique variable value, it would be easy to just check the value - but what object contains the interacted instance ? every example/method i have come across in these forums so far just gives the object of the first instance on the screen (objects[0].etc.etc) rather than the one touched.

(since there are 160+ betpads on screen (invisibly, they are just there as user-input definitions), tihs must be done in a JS code block, it would be unreasonable to setup visual rules for each one individually)

You can pass an object to a JS event at the top:
passtojs

After that, objects[0] the first element in the array should always return the instance that fulfilled the condition.
Make sure the JS event is a sub event of the condition you want to test.

1 Like

Ahh yes, that works! :slight_smile: thank you very much!