How can I return this data from Function ?

The thing is I want to do is get the Y position and show some effects when user went in this position. I know I can create an anchor and use onviewEnter() but I want to learn with this way also.