Hi all,
I’m trying to trigger a javascript function in a pano with a hotspot. The javascript function triggers a handler outside of the vr in a LiveCode project.
I am not a javascript programmer and have a very basic understanding of javascript.
I started by getting some basic javascript working by using the Pano2VR javascript api. I used: javascript:pano.enterFullscreen() in a hotspot and it worked great.
Now I want to trigger a function via an addListener event. Here is what I have:
I have created a skin for a hotspot and selected Go to URL as the action and
javascript:pano.event.addListener('jp_hotspot','click', function() {liveCode.myLiveCodeHandler();}); as the text of my URL.
The panorama loads, but the expected click function is not occurring.
My example is based on a Google Maps example that triggers a javascript function when the user clicks on a map marker. The Google map example is: google.maps.event.addListener(marker, 'click', function() {
liveCode.myLiveCodeHandler();
});
The Google Maps example works in a browser object in a LiveCode (www.livecode.org) Project. The browser object in the LiveCode project consists of a Google Map with a map marker. Clicking the Google Map marker triggers the Javascript code that is then captures by the LiveCode project and executes the functions handler.
The ability to trigger a javascript function from the pano and then have LiveCode intercept and execute on that function, enables many more capabilities.
I guess my question is can a execute a javascript function, that is not part of the Pano2VR js api, from a hotspot action? And, what would the code look like to make that happen?
Thank you!
John Patten
SUSD
Hotspot Javascript and onclick function triggering?
Why does that answer always come to you after you post a cry for help?!!
I had:
pano.event.addListener('jp_hotspot','click', function() {liveCode.myLiveCodeHandler();});
which should have been:
window.addEventListener('click', function() {liveCode.myLiveCodeHandler();});
"pano." does not have an addEventListener defined for it. I think that was the reason why this was not working. I hadn't realized I could use document.addEventListerner, or window.addEventListener in the javascript of the skin.js. Chalk one up to inexperience with javascript.
Cheers!
I had:
pano.event.addListener('jp_hotspot','click', function() {liveCode.myLiveCodeHandler();});
which should have been:
window.addEventListener('click', function() {liveCode.myLiveCodeHandler();});
"pano." does not have an addEventListener defined for it. I think that was the reason why this was not working. I hadn't realized I could use document.addEventListerner, or window.addEventListener in the javascript of the skin.js. Chalk one up to inexperience with javascript.
Cheers!