• is this supposed to actually add a hotspot? for example if I click a button it will add a new hotspot to the scene?


    addhotspot(newspot);
    set(hotspot[newspot].url,spot.png);
    set(hotspot[newspot].ath,150);
    set(hotspot[newspot].atv,30);
    set(hotspot[newspot].scale,0.7);
    set(hotspot[newspot].zoom,true);
    set(hotspot[newspot].onclick, removehotspot(newspot) );
    I tried to use this example from the documentation and I cannot get it to work. I keep getting:
    "ERROR: hotspot[newspot] - loading of 'hotspot.png' failed!"
    this is the action that I am calling. The image is in the right spot because I am using it in the same scene for hotspots not created dynamically


    <action name="addhot2spot">
    addhotspot(newspot);
    set(hotspot[newspot].url,hotspot.png);
    set(hotspot[newspot].ath,150);
    set(hotspot[newspot].atv,30);
    set(hotspot[newspot].scale,0.7);
    set(hotspot[newspot].zoom,true);

    </action>

    and then something like: onclick="addhot2spot();"


    can you point me to a good example of adding a hotspot dynamically?
    Thank you *smile*

  • As clearly stated in your error log path to image is not correct. As you are not using path placeholders take care that path to image file is relative to xml file where your action is started.
    Or you save image to same folder where xml file is or use e.g.
    set(hotspot[newspot].url,'%SWFPATH%/folder_where_image_is_stored/your_file.png');

    Edited once, last by Umalo (February 23, 2017 at 3:49 PM).

  • Thank you for your response
    The path was ok and I did have the image in the same folder as the xml .

    I am using the draggable hotspots example. I'm thinking that when I click on "spot3" it will call "addhot2spot" and a new hotspot will be created named "newspot"? I always get " hotspot[newspot] - loading of './hotspot.png' failed! "

    I also tried all of the following
    set(hotspot[newspot].url,'%SWFPATH%/hotspot.png');
    set(hotspot[newspot].url,%SWFPATH%/hotspot.png);
    set(hotspot[newspot].url,%SWFPATH%/"hotspot.png");
    set(hotspot[newspot].url,"hotspot.png");
    set(hotspot[newspot].url,hotspot.png);

    and also moved it to an images folder and tried all the above combos with that path;
    set(hotspot[newspot].url,'%SWFPATH%/images/hotspot.png');


    Here is the code, it is just the dragable hotspots with an action to create a hotspot.

    <action name="addhot2spot">
    addhotspot(newspot);
    set(hotspot[newspot].url,"hotspot.png");
    set(hotspot[newspot].ath,50);
    set(hotspot[newspot].atv,-25);
    set(hotspot[newspot].scale,0.7);
    set(hotspot[newspot].zoom,true);

    </action>


    <hotspot name="spot2" url="hotspot.png" zoom="true" scale="0.5" ath="0" atv="+25" ondown="draghotspot();" />


    <hotspot name="spot3" url="hotspot.png" distorted="true" scale="0.5" ath="+25" atv="+5" ondown="addhot2spot();" />
    <hotspot name="newspot2" url="hotspot.png" scale="0.5" ath="-25" atv="+29" ondown="draghotspot();" onclick="addhot2spot();" />

  • It must work.

    If the file is in the same location as the main xml then try.

    <action name="addhot2spot">
    addhotspot(newspot);
    set(hotspot[newspot].url,hotspot.png);
    ...
    </action>

    or

    <action name="addhot2spot">
    addhotspot(newspot);
    set(hotspot[newspot].url,%FIRSTXML%hotspot.png);
    ...
    </action>

    best regards
    Piotr

  • Thank you *smile*

    That worked (%FIRSTXML%)

    I wish I understood why all the others did not, especially since that's how they are in the docs and I've seen examples posted on the form without that.

    from docs, doesn't work:

    addhotspot(newspot);
    set(hotspot[newspot].url,spot.png);
    set(hotspot[newspot].ath,150);
    set(hotspot[newspot].atv,30);
    set(hotspot[newspot].scale,0.7);
    set(hotspot[newspot].zoom,true);
    set(hotspot[newspot].onclick, removehotspot(newspot) );


    But that works perfectly.
    Thank you so much *smile*

Participate now!

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