Getting access to the layer through javascript. NPObject Error

  • Hello!

    I make map and I'm trying to get access to the layer with map marker using javascript:
    Code:
    krpano.set('layer[layerName].style, map_marker_active');

    Also, if I send this string to the console:
    document.getElementById('krpanoSWFObject').get('layer[map]');
    Appears the same error.

    At the same time, if i send this string to the console:
    document.getElementById('krpanoSWFObject').get('scene');
    All right :(

    XML file, javascripts and swf are on the same server.
    Only if I want to do something with layer or plugin - I get this error.

    Please help! Error text:
    Chrome: Uncaught Error: Error calling method on NPObject.
    Firefox: uncaught exception: Error in Actionscript. Use a try/catch block to find error

    How can I solve this problem?

    I apologize for my English.

  • Hi,

    some Flash Actionscript 3 Object can't be converted to Javascript Objects (e.g. when they are containing Flash native DisplayList elements).
    Try to access only 'normal' krpano properties like Numbers or Strings instead.
    Flash objects itself couldn't be used in Javascript anyway.

    Best regards,
    Klaus

  • Thanks for the reply!
    But why I can change fov or hlook, and can't change the layer style?
    I would like to understand the situation. I want to understand, that such issues no longer occur.

  • Hi,

    first you need to know that the Flashplayer and Javascript are two different 'worlds' - they are not directly compatible, they communicate via internal/hidden/automatic interfaces.

    When passing Number or Strings from Flash to Javascript or from Javascript to Flash, then these interfaces are automatically do the conversion in behind.

    Passing Objects is possible too, but there the interface is not passing the Object itself, instead it creates a new Object and tries to copy and convert all properties. And here the problem begins - some Flashplayer Objects/properties can't be converted, e.g. when an Object contains a Flashplayer native 'Sprite' Object, then it is not possible to convert that to Javascript - an error will be thrown in that case.

    That means as long as you are only setting/getting the normal krpano settings/properties, then there is no problem, but when trying to get a whole Objects, it will fail.


    Btw - this code here is wrong:
    krpano.set('layer[layerName].style, map_marker_active');
    correct would be - two parameters - the property and its value:
    krpano.set("layer[layerName].style", "map_marker_active");

    Best regards,
    Klaus

  • Thank you very much for your help.
    I solved the problem by calling the krpano action in Javascript with params.

    At the same time I was faced with another problem.
    get(layer[layerName].style) always null :(

Participate now!

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