creating polygonal hotspot from as3

  • Hello,

    When I try this, it works fine:

    krpano.call("addhotspot(myhotspot);");
    krpano.call("set(hotspot[myhotspot].point[0].ath,-10)");
    krpano.call("set(hotspot[myhotspot].point[0].atv,-10)");

    But when after creating the hotspot I get its instance to do this:


    krpano.call("addhotspot(myhotspot);");
    var hs1=krpano.get("hotspot[myhotspot]");
    hs1.point[0].ath=-10;
    hs1.point[0].atv=-10;

    I get this error:
    Property 0 not found in krpano.Kinterface.Kinterface_array and there is no default value.

    It seems to be about the point array doesn't exists but I can't understand why the second method is different than the first one.

    Any help would be appreciate

  • Hi,

    a krpano array is internally not directly an AS3 array (e.g. you can access elements in a krpano array by name or by index, this is not possible with an normal array), but there is a way to get an AS3 array in flash by using the 'getArray()' function,

    e.g.

    Code
    var hs1=krpano.get("hotspot[myhotspot]");
    var pointarray:Array = hs1.point.getArray();
    pointarray[0].ath=-10;
    pointarray[0].atv=-10;

    but note - with that you can only edit existing point elements,
    if you want to add a new array element direct with AS3 there is a 'createItem(name)' function,
    e.g.

    Code
    var hs1=krpano.get("hotspot[myhotspot]");
    hs1.point.createItem("point1");
    var pointarray:Array = hs1.point.getArray();
    pointarray[0].ath=-10;
    pointarray[0].atv=-10;

    best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!