Variable not being passed, script had been working for 8 mos?!?

  • Having problems passing a variable.
    This script has worked for the past 8 months or so just fine, but as of last Friday the var hs1 is not being passed from the setInterval() function in start_getspot() to getspot().
    When keeping an eye on things with the Developer tools in Chrome, I keep getting the error:
    "Uncaught ReferenceError: hs1 is not defined"
    Which is obviously being caused by hs1 not being passed to the getspot() function.
    It would seem that my syntax in the setInterval() function is wrong, and not passing or defining hs1. But this has worked for sooooo long with no issues?!?!?!?

    I've inserted several alerts to debug this and have added **** comments **** to show what is going on on the flow of the script....

    var spot_interval;

    function krpanospot()
    {
    return document.getElementById("krpanoObject");
    };

    function getspot(hs1)
    {
    alert("hs1="+hs1); **** NO ALERT ****
    var hs2 = hs1;
    var hspot = Number( krpanospot().get("hotspot[hs2].ath") );
    var vspot = Number( krpanospot().get("hotspot[hs2].atv") );
    //var fov = Number( krpano().get("view.fov") );

    document.getElementById("spotath").value = hspot.toFixed(2);
    document.getElementById("spotatv").value = vspot.toFixed(2);
    // document.getElementById("fov").innerHTML = fov.toFixed(2);
    };

    function start_getspot(hs)
    {
    alert("hs="+hs); **** AS EXPECTED ****
    var hs1 = hs;
    alert("hs1="+hs1); **** AS EXPECTED hs1 IS PASSED AND SHOWS UP IN ALERT ****
    spot_interval = setInterval( 'getspot(hs1)', 66 );
    };

    I backup the entire web-app I'm working on every day, so I have historical snapshots of every phase of development.
    So, I've loaded completely historic versions of the system, that definitely worked. But nothing seems to solve this mystery.
    I've tried loading in several of the older versions to no avail ( same results ). This is also browser independent since it occurs on Safari, Chrome FF and IE on Mac and Windows.
    I've tried backing off the version of FLASH, the version of KRPano, older versions of safari.....

    What still is very odd is that this happened out of nowhere. I did not change any of this scripting. Had not updated ANYTHING over the past week or so.
    *wacko*

  • Got the variable passing but now another issue.....I get the following error....
    "Uncaught TypeError: Object #<HTMLEmbedElement> has no method 'get'"


    GSome how my reference to KRPano is not being resolved.


    But utilizing the same exact code in several other places KRPano resolves and I'm able to "get" with no issues.


    Here is the revised code that passes the var but receives the "no get method" error.


    var spot_interval;

    function krpano()
    {
    return document.getElementById("krpanoObject");
    };

    function getspot(hs1)
    {
    hs2 = hs1;
    var hspot = Number( krpano().get("hotspot[hs2].ath") );
    var vspot = Number( krpano().get("hotspot[hs2].atv") );
    //var fov = Number( krpano().get("view.fov") );

    document.getElementById("spotath").value = hspot.toFixed(2);
    document.getElementById("spotatv").value = vspot.toFixed(2);
    // document.getElementById("fov").innerHTML = fov.toFixed(2);
    };

    function start_getspot(hs)
    {
    hs1 = hs;
    spot_interval = setInterval( function() {getspot(hs1);}, 66 );
    };

  • Seems that for some reason the setInterval - passing a variable - issue was what was binding things up.
    I reworked some things to eliminate the need to pass the variable and everything fires off just fine.

    GREAT!

    But what concerns me is WHY did this work for soooo long and then one day quit?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!