Javascript: Why do some calls work and others not?

  • Probably a small problem.


    A customer wants to control many things from HTML buttons.
    My interface, that emulates the flat skin buttons, works well for controls like zoom in/out, move up/down/left/right and even change of control mode.
    But for some unknown reason zoom in/out and reset won't work.

    I'm not new to programming, but Javascript has not been on my priority list, so I might just be goofing around.
    I have tried different approaches like switch(screenmode), set("fullscreen, true"), and also updated the panorama afterwards, but no luck.
    I have also checked that I have the latest krpano files (1.0.8.11).

    The source code lists the javascript functions I use, and the HTML button code.
    I suspect that the krpano calls can be made simpler.

    Can anyone help?

    *huh* Sven


    Test site -------------------------------------

    http://sphaerama.com/_test/medvind/panoramas/test/pano.htm

    Javascript ------------------------------------

    var dc = false

    function krpano() { return document.getElementById('krpanoSWFObject');}

    function moveup() { krpano().call("set(vlookat_moveforce, -0.3)"); }
    function movedown() { krpano().call("set(vlookat_moveforce, 0.3)"); }
    function moveleft() { krpano().call("set(hlookat_moveforce, -0.3)"); }
    function moveright() { krpano().call("set(hlookat_moveforce, 0.3)"); }
    function movestop() { krpano().call("set(hlookat_moveforce, 0)");
    krpano().call("set(vlookat_moveforce, 0)"); }

    function zoomin() { krpano().call("set(fov_moveforce, -0.3)"); }
    function zoomout() { krpano().call("set(fov_moveforce, 0.5)"); }
    function zoomstop() { krpano().call("set(fov_moveforce, 0)"); }

    function reset_view() { krpano().call("set(zoomto(1.0, smooth(3,3,10)))"); }
    function full_scr() { krpano().call("switch(fullscreen)"); }

    function drag_cursor() { krpano().call("set(control.mousetype, drag2D)");
    krpano().call("set(cursors.url, ../../images/drag-cursors.png)");
    krpano().call("set(cursors.type, drag)");
    krpano().call("set(cursors.move, 2|0|30|32)");
    krpano().call("set(cursors.drag, 37|0|30|32)"); }
    function qtvr_cursor() { krpano().call("set(control.mousetype, moveto)");
    krpano().call("set(cursors.url, ../../images/qtvr-cursors.png)");
    krpano().call("set(cursors.type, 8way)");
    krpano().call("set(cursors.move, 0|0|16|16)");
    krpano().call("set(cursors.drag, 16|0|16|16)");
    krpano().call("set(cursors.arrow_u, 32|0|16|16)");
    krpano().call("set(cursors.arrow_d, 48|0|16|16)");
    krpano().call("set(cursors.arrow_l, 64|0|16|16)");
    krpano().call("set(cursors.arrow_r, 80|0|16|16)");
    krpano().call("set(cursors.arrow_lu, 96|0|16|16)");
    krpano().call("set(cursors.arrow_ru, 112|0|16|16)");
    krpano().call("set(cursors.arrow_rd, 128|0|16|16)");
    krpano().call("set(cursors.arrow_ld, 144|0|16|16)"); }
    function change_cursor() { if (dc == true) { drag_cursor(); dc = false;} else { qtvr_cursor(); dc = true; } }

    HTML ---------------------------------------------
    <img src="../../images/zoom_in.gif" onmousedown ="zoomin()" onmouseup="zoomstop()" >
    <img src="../../images/zoom_out.gif" onmousedown ="zoomout()" onmouseup="zoomstop()" >
    <img src="../../images/move_left.gif" onmousedown ="moveleft()" onmouseup="movestop()" >
    <img src="../../images/move_right.gif" onmousedown ="moveright()" onmouseup="movestop()" >
    <img src="../../images/move_up.gif" onmousedown ="moveup()" onmouseup="movestop()" >
    <img src="../../images/move_down.gif" onmousedown ="movedown()" onmouseup="movestop()" >
    <img src="../../images/reset.gif" onclick ="reset_view()" >
    <img src="../../images/move_normal.gif" onclick ="change_cursor()" >
    <img src="../../images/screen_full.gif" onclick ="full_scr()" >

  • Hi Sven,

    This line is not correct:

    Code
    function reset_view() { krpano().call("set(zoomto(1.0, smooth(3,3,10)))"); }


    it should be:

    Code
    function reset_view() { krpano().call("zoomto(1.0, smooth(3,3,10))"); }

    About the fullscreen from within Javascript, is a flash security limitation , have a look here

    Hope this help...

    SAlut.

  • *thumbup* Thank you very much michel!


    The reset problem was due to me - mindlessly copying code - and your correction works as it should.

    Security restrictions in Flash you just have to live with, and I'll place the full screen button in the panorama.


    Sven

Participate now!

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