action to set properties on all hotspots

  • I've created an action to add a duplicate hotspot with different values to get over the problem I found in this post . i.e. you need 2 hotspots if you want to have a graphic in a polygonal hotspot.

    Ideally this would be called when each hotspot is loaded, but onloaded="" doesn't work on a hotspot.

    Is there a way of creating an action that can be run when the scene is loaded that applies my action to all hotspots?

  • Hi,

    looping through all hotspots can be done with this actions for example (with beta 9 there will also be an easier method)

    e.g.

    best regards,
    Klaus

  • Cheers Klaus,

    That kind of works - only it replaces the hotspots I'm trying to duplicate with the new hotspots. This is how I'm using it -

    Code
    <action name="loop_all_hotspots">set(i,0);loop_all_hotspots_next(get(i));</action><action name="loop_all_hotspots_next">trace(hotspot[%1].name);addhotspot(%1);set(hotspot[%1].atv,get(hotspot[%1].atv));set(hotspot[%1].ath,get(hotspot[%1].ath));set(hotspot[%1].url,%SWFPATH%/hs.png);set(hotspot[%1].scale,get(hotspot[%1].scale));set(hotspot[%1].enabled,false);set(hotspot[%1].keep,false);set(hotspot[%1].zorder,-100);set(hotspot[%1].edge,bottom);inc(i);if(i LT hotspot.count, loop_all_hotspots_next(get(i)));</action>


    What I want to do is create new hotspots so tried things like this:

    Code
    <action name="loop_all_hotspots">set(i,0);loop_all_hotspots_next(get(i));</action><action name="loop_all_hotspots_next">trace(hotspot[%1].name);addhotspot(%1_new);set(hotspot[%1_new].atv,get(hotspot[%1].atv));set(hotspot[%1_new].ath,get(hotspot[%1].ath));set(hotspot[%1_new].url,%SWFPATH%/hs.png);set(hotspot[%1_new].scale,get(hotspot[%1].scale));set(hotspot[%1_new].enabled,false);set(hotspot[%1_new].keep,false);set(hotspot[%1_new].zorder,-100);set(hotspot[%1_new].edge,bottom);inc(i);if(i LT hotspot.count, loop_all_hotspots_next(get(i)));</action>


    And it only works on the first hotspot. Any ideas? *pinch*

  • Doing this:

    Just deletes the first hotspot, does the right thing on the second hotspot, and ignores the third one!

  • Hi viewinz,

    The bigger mistake in your code is how the z-order is set.... *sad*

    • There is a strange behaviour on setting the z-order attribute when it is call after setting the ath and atv attributes *attention* . I do not know why ( KLAUS please *smile* , some explanation here )... *wacko* It MUST be set before the ath and atv attributes.
    • You have put a value of -100 for z-order. Better will be positive value: 100.

    The way the hotspot.count is used it is not optimal... because each addhotspot() increase the hotspot.count value *attention* You have to "freeze" the hotspot.count at the moment of the calling action.

    Adding a new hospot with %1_%1 as argument, addhotspot(%1_%1);, seems to result on strange behaviour too.... I do not know why......

    Finaly, no needs of the 3 actions... 2 actions are sufficient.

    Here is a code to test the modified actions.. change the hotspot images with yours.

    I hope this can help. Tell me please. *wink*

    Salut.

  • Michel,


    Thanks so much for this it works nearly perfectly!


    It's generating an extra 3 hotspots, see here -



    And another small problem is that I want to make these disapear with an onover action from the original hotspots using the hotspot name. Before I was using something like this:

    Code
    trace(name);
      hs_text_set(get(name),get(lang));
      hs_text_graphic_off(get(name));
        
      
      set(hotspot[truc_%1].visible,false);
      set(hotspot[truc_%1].onout,set(hotspot[truc_%1].visible,true));
      
      
      set(hotspot[%1].onhover,showtext(get(data[%2_%1].content),hs));


    I tried to get it to trace the name and use that instead of the hotspot count but it's not working? Any ideas?


    Thank you so much for your help with this! *g*

    EDIT: Fixed the extra hotspot problem by calling the action later after the intro.

    Still would like to find a way of making the new names the same as other original name with the 'truc_'!?

    Edited once, last by viewinz (September 26, 2009 at 9:24 AM).

  • Hi viewinz,

    Quote

    Still would like to find a way of making the new names the same as other original name with the 'truc_'!?

    I have made some changes into the code to retrieve the name of the original hotspot to use it as first part of the added hotspot. The code becomes like this:

    Can you give a link to see what you are trying to do? It is really difficult to understand your goal.
    For example, what element is the one that call the actions above? What is the goal? Perhaps to substitute the originals hotspot? If so, why to not change the attributes of those originals hotspot (the url value for example)?...

    Quote

    It's generating an extra 3 hotspots, see here -

    I do not really understand what you are talking about... Is it because the actions are called 2 times?
    Anyway, I have noticed an other strange behaviour on the code above... The first call seems to work correctly... But if you make a second call, then there is one added hotspot with scale=1 instead of 0,5... I really do not understand why... *sad*

    Salut.

  • Actually, I'm getting very strange behaviours also.

    Sometimes it keeps the hotspot from the previous scene that called the loadscene. Even though that one is set keep=false!?

    Very strange.. *cry*

    They are always fine on the first call, maybe I should remove all created hotspots when a new scene is loaded, and re-call this action?

    To answer your question:

    Quote

    Can you give a link to see what you are trying to do? It is really difficult to understand your goal.
    For example, what element is the one that call the actions above? What is the goal? Perhaps to substitute the originals hotspot? If so, why to not change the attributes of those originals hotspot (the url value for example)?...


    All my hotspots are polygonal (this is for consistency). I want to have a graphic that shows when close to the point of view, as with the other thread. To keep the polygonal hotspot and make the whole area clickable, I need to have another hotspot with the graphic that is generated in the above action.

    So they are duplicates of existing hotspots.


    p.s. site is viewnz.net

    Edited 2 times, last by viewinz (September 27, 2009 at 7:38 AM).

  • Sometimes it keeps the hotspot from the previous scene that called the loadscene. Even though that one is set keep=false!?

    Very strange.. *cry*

    They are always fine on the first call, maybe I should remove all created hotspots when a new scene is loaded, and re-call this action?

    Hi,

    I think this is the problem:
    you need to call the loadscene() with the MERGE flag,
    e.g.

    Code
    loadscene(scenename, null, MERGE);

    best regards,
    Klaus

  • Hi Klaus, thanks for your help - that doesn't seem to have made any difference.

    Can you have a look at my example?

    The problem appears when you click on the hotspot on the beach. Here are the original beach hotspots:



    There are 3 hotspots:

    • beach2ferry
    • beach2pier
    • beach2marineparade


    So when I run the action to create the new hotspots that Klaus and Michel helped me with I should get 6 hotspots:


    original(polygonal)

    original_(graphical)

    • beach2ferry
    • beach2pier
    • beach2marineparade
    • beach2ferry_
    • beach2pier_
    • beach2marineparade_


    Here is what gets generated by Michel' action -


    • pier2beach_
    • beach2ferry
    • beach2pier
    • beach2marineparade
    • beach2ferry_
    • beach2pier_
    • beach2marineparade_


    The top hotspot, "pier2beach_" is a relic from the previous scene. And is the hotspot that called the next scene. This hotspot name is stored in the trace(name) from the hotspot action I use to look at the hotspot when you call it (see below).


    As you can see, I am using MERGE in the loadpano and all hotspots are keep=false.

    Edited 4 times, last by viewinz (September 29, 2009 at 5:02 AM).

  • Hi viewinz,

    I think the action code that add the hotspots is not the cause of the problem....
    Try using this:

    Code
    <action name="loop_all_hotspots">
    		trace('hotspot.count = ',hotspot.count);
    	</action>

    The hotspot.count has 1 more hotspot... the relic one...

    I am sure the problem comes from your <action name="hs_text"> and the others actions called from him *attention*

    Try using this code:

    Code
    <action name="hs_text">
    		trace(name);
    		</action>

    You will notice that the hotspot.count is correct now....

    At this moment I do not know where is the problem on the hs_text() action... maybe later... *rolleyes*

    Salut.

  • Hi

    The problem seems to come from the hs_text_graphic_off() action.... I do not understand why at this moment...
    Try to simply make this action empty to see if all the others things work well:

    Code
    <action name="hs_text_graphic_off">
    		</action>

    Salut.

  • Hi viewinz,

    The line of code that makes the mistake into hs_text_graphic_off() action code is:

    Code
    set(hotspot[%1].onout,set(hotspot[%1_].visible,true);


    I do not know why... *sad*
    In trying to understand what happens here, I imagine that perhaps the hotspot[%1].onout attribute can not be changed because it is currently in use (onover)..... and then krpano create an new hotspot[%1] to be able to set the onout attribute... JUST IMAGINATION *rolleyes* .... but.... *whistling*

    Perhaps KLAUS can explain us what is happening here. *smile* Please *thumbsup*

    Salut.

  • Hi,

    wow, I got it now, it's a very complex problem

    the main problem is the usage of the "onviewchange" event in combination the "lookto/wait" actions,

    the lookto/wait actions are "blocking" actions (for historical reasons, but I'm planing to change that in some way...)
    all other actions that were called while a lookto action is running will be queued,

    now here is the problem:
    - the onviewchange event is set to an action with a lot of commands
    - a lookto action happens
    - the onviewchange event will be called every frame during the lookto movement
    - but the actions from the onviewchange event are NOT executed (because of the "blocking")
    - instead these actions were queued for later execution
    - and finally the number of actions to execute became just TOO MUCH

    as quick solution would be to disable the calling of the onviewchange event, during an "blocking" action
    (I have done this for testing direct in krpano and it would work (test version via mail if interested), I think I will integrate it in the next release,
    but I will also try to improve the actions execution to allow more commands at once),

    btw - the usage of the onviewchange here is no very efficient - do you have some as3 (or programming) knowledge?
    doing the same in as3 code (as plugin) should work much better...

    best regards,
    Klaus

  • Klaus - Thank you for looking at this.

    Basically I think what your saying is that I asked it to do too much and broke it! Standard procedure for me..

    My AS3 isn't good, I've tried a few things and run into a load of errors and don't know how to fix them.. Might have to hire someone to help!
    How would you suggest making it into a plugin?

    Does the test you've done stop the problem happening? i.e. fix it? Please email it to me when you get the chance!

  • Hi viewinz,

    the main problem is the usage of the "onviewchange" event in combination the "lookto/wait" actions,

    After reading the post from Klaus, I was thinking in erasing the onviewchange event to see if the Relic hotspot problem become solved... then I do... into the <action name="normalview" i have erased the line set(events.onviewchange,show_hotspots_in_range()); . But the Relic Hotpot is always here... *wacko*

    Then I do not understand... *sad*

    Salut.

  • Hi viewinz,

    Ok, Another way I found to get the hotspot.count correct is only making changes in the hs() action... I have commented the looktohotspot() and the wait(load) , like this:

    Doing this way, you do not loose the hs_text_graphic_off() action but you loose the looktohotspot.
    At least the relic hotspot disappear...

    Salut. *sleeping*

Participate now!

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