• I've been struggling for the last few days with a weird behavior, which is certainly ruining my humour. *wacko*

    I sincerely hope that after I've explained my problem here, I will suddenly find the solution myself (as has happened before). So, here it comes.

    My purpose is to show a whole house. So initially, krpano opens on a specific floor and room (full panorama). On the top left, it shows the floorplan of that floor, and on the left bottom, it shows a little map of the whole house, which I'll call the house map.

    On the floorplan one can select different rooms on the same floor. If one clicks on a pano icon on the floorplan, that pano opens. So far, so good.

    On the house map, one can select a different floor, with a new set of panos. When one clicks on another floor in the house map, then the default pano for that floor loads, and the new floorplan appears on the left top. BUT! Now the pano icons are no longer displayed on top of the floorplan, but apparently behind it (semi-visible because of alpha value 0.90 of floorplan)! *cursing*

    I have not been able to find any bug in my code. The very same code that is used to show the pano icons (image plugins) initially, is also used to display them again after changing the floorplan. They are created on the fly, using "addplugin".

    The zorder values (which are about the only things I could think of that could make the icons appear behind the floorplan instead of on top) of both the parent plugin (floorplan) and its children (pano icons) are correct. I can see this when I open the xml in the editor plugin: all the properties of the plugins look perfectly alright, there is no difference between the values as they are when the icons show properly, and the values as they are when the icons don't show. Then, when I click "Load this xml" (without having changed a thing), suddenly the icons are there, as if nothing was ever wrong.

    Does anyone have any clue about this spooky behavior?

    I tried saving the whole xml to a file, both when the icons show, and when they don't show, and then sorted the contents of both files alphabetically (because not all plugins are shown in the same order each time), and then did a file compare of the sorted files. The only difference was the amount of empty lines. *huh*

    The xml editor unfortunately only includes the things it knows, so it does not include any of the user data which is inside the original xml (the data that defines the contents of my floors, list of my panos, etc.). But still I'm at a loss what the contents of that data could have to do with my icons showing behind the floorplan instead of in front.

    How to reproduce the problem:

    • Go here. You will see that the pano icons are present, on the top left.
    • click on "penthouse" on the left bottom, so that its floor loads
    • click again on the garden (little tree), so that the garden loads
    • now you are back at the first place, but you will see that the pano icons are absent on the top left.
    • Feel free to compare the plugin values in the xml editor. Feel free to press "load this xml" and stuff like that.

    PS. Already on "penthouse", the icons are missing, but it is easier to compare behavior on the same pano.

    This is a copy of my project and will stay untouched until a solution is found.

    Thanks very much in advance.

    - Ronny D'Hoore

  • Tuur, thanks, but I tried any initial zorder, it doesn't make matter if it is just 1 more or 100 more...

    PS. For those who are willing to sleuth, I forgot to mention that the tours start with the action called "init", which then calls new_floor(), which in turn calls create_plugin_set() in a foreach loop, and then showmap() to show the whole thing.

    - Ronny D'Hoore

  • do i understand right and are your spots child to the map?? the right map?

    also watch out for giving things a name that you already use...
    *confused*


    Tuur *thumbsup*

  • do i understand right and are your spots child to the map?? the right map?

    Yes, that is correct, they are created as children of "plugin[map]" (which simply gets a different url assigned when a different floor is selected). The first time it works fine, but the next times they seem to be behind the map.

    also watch out for giving things a name that you already use...

    Do you mean through addplugin()? I'm first removing any existing pano icon plugins with removeplugin() before creating the new ones. And when I inspect the xml through the online editor, indeed I don't find any traces of old icon plugins.

    Or if you mean by using a global variable for two different purposes at the same time, I was quite careful with that. I'm certainly reusing variables, but never concurrently, as far as I can see.

    PS. I just changed the alpha value for the plugins from 0.9 to 0.7, because then it becomes very obvious that after changing floors, indeed the icons end up behind the floorplan instead of on top of it, despite their zorder...

    - Ronny D'Hoore

  • I'm getting somewhere now: I figured out that the icons end up behind the floorplan as soon as I assign a different url to the floorplan (called plugin[map]). Because when I don't assign a new url (so I keep the original jpg just to test), then the new icons do appear in front of the floorplan (of course all in seemingly wrong places, because it's the wrong jpg now).

    In other words, when I change this:

    Code
    txtadd( plugin[map].url, get(imgdir_tour_url), "FloorMap/", get(floordata.map) );


    into this:

    Code
    if (plugin[map].url === "",
    	                txtadd( plugin[map].url, get(imgdir_tour_url), "FloorMap/", get(floordata.map) );
    		);

    So I'm starting to guess only Klaus can answer this question:

    What happens exactly when one assigns a new url to a plugin? Is there any reason that child plugins could suddenly appear behind the plugin, despite having a higher zorder?
    And why does it work the first time I assign a url (when there was none yet), but not the next times (when there was already one)? *confused*

    Thanks

    - Ronny D'Hoore

  • why not make just a second plugin? instead of changing the url...??

    maybe the 'parsing' of the code has to do with it?

    Tuur *thumbsup*

  • Quote

    why not make just a second plugin? instead of changing the url...??

    I was not aware that re-assigning a url was a bad practice. I do recall Klaus writing about it in the forum, but now I can't find it back. My intention was to save memory, as each full-size floorplan is quite large (I need them in full size on the web page containing the link to the pano viewer).

    I guess I could try deleting plugin[map] in the code as well, and then recreate it, and see what happens.

    But surely I would like to know why it is doing like that. Especially the fact that at the point where it does not show the icons, when you press "editor", "xml" and then "load this xml" (without having changed anything), then they are there. I'm starting to think in the direction of a bug or "undocumented feature"...

    - Ronny D'Hoore

  • I followed Tuur's advice, and replaced


    Code
    txtadd( plugin[map].url, get(imgdir_tour_url), "FloorMap/", get(floordata.map) );


    by

    Further on in the code, some of these properties will get replaced by custom values, but the above values are also the initial values for this plugin as in the xml.

    So, now the pano icons do appear on top of the floorplan after changing floors, as they should... *blink*

    I'm even more convinced now I met a bug, because as soon as I remove the lines

    Code
    removeplugin(map);
    	addplugin(map);


    in the section above (leaving the rest in place), the pano icons again end up underneath the floorplan after changing floors, where they certainly should not be.

    Anyway, as I need to move on, I will surrender to this (Tuur's) solution.
    Tuur, thanks very much for taking the time to help thinking with me. *thumbup*

    - Ronny D'Hoore

  • Hello. From my knowledge of Flash and Actionscript, when you change the URL of a plugin, since you end up with a completely different plugin - as far as krpano can tell - it must effectively delete and add the plugin again. Thing is, if krpano uses the addChild method, which is the default method for adding a displayobject-based entity, the entity is always placed on top of all existing entities in the same node of the display tree, regardless of their current z-indices. In other words, if you have 1, 2 and 100, it will be added to position 101. See here:

    http://www.adobe.com/livedocs/flash…#addChild%28%29

    Internally, when copying a plugin, krpano probably copies all the attributes (x, y, scale, hand cursor, etc.) to the newly created plugin and only in the very end uses addChild - most of us AS developers do it like this because when the plugin shows up, it will be already fully configured and in the correct position/state. I'm not sure exactly what Klaus does about the z-index in this event - He may be trying to use setChildIndex before addChild and then catching the error, or simply ignoring it.

    Conversely, when you use addplugin, it creates the plugin and then adds it as a child to its parent DisplayObjectContainer, and only AFTERWARDS do you set the z-index, which is why it ends up in the correct layer!

  • Hello Protected,

    Thank you so much for your detailed explanation. I appreciate it very much.

    I had no clue that to change the url, it means that internally the plugin must be recreated. So, if I understand all this properly, then the correct thing would be to use addChildAt() instead of addChild().

    But as we as krpano users have no influence on this, the only option I have is to remove the plugin and create it again, as I'm doing. Still, it is nice to see that there is some sense behind the weird behavior :)

    - Ronny D'Hoore

  • Hi Ronny,

    Here my scratching the head solution *g* ...

    On the new_floor() action, after your:

    Code
    txtadd( plugin[map].url, get(imgdir_tour_url), "FloorMap/", get(floordata.map) );


    add this line:

    Code
    txtadd( plugin[map].scale9grid, "0|0|",get(floordata.width),"|", get(floordata.height) );

    *rolleyes* ...

    It seems that setting a scale9grid for the plugin avoids the problem....

    Hope this can be useful..

    SAlut.


  • It seems that setting a scale9grid for the plugin avoids the problem....

    Michel, you are entirely correct, as usual. I'm quite impressed indeed. *thumbup*

    I have one more riddle, it is not too disturbing, but still I wonder why when one hovers the mouse over a blue pano icon, the red icon very briefly flashes somewhere on top of the panorama, before appearing on the right place. It looks as if krpano first displays the red icon calculating its x and y (in %) in respect to the whole screen, and only then figures out that it should be in respect to its parent, which is the floorplan.

    The onover does not do any changing of x and y values, it simply makes the red icon (hs_pano_0xx_select) visible and makes the blue one (hs_pano_0xx) transparent:

    Code
    onover="set(plugin[hs_pano002_select].visible, true ); set(plugin[hs_pano002].alpha, 0);"

    I suppose I could solve it by making all plugins visible and then immediately invisible again, while the floorplan is still off-screen. But still I find this behavior intruiging, and wonder if anyone else has noticed such an "undocumented" behavior with his image plugins, and has some trick to avoid it?

    PS. It appears in the wrong place only the first time you hover the mouse over it, after that, it behaves properly.

    - Ronny D'Hoore

  • Hi Ronny,

    Quote

    ...the red icon very briefly flashes somewhere....

    It seems to be some behaviour with the alignment of the children of a parent.....
    Like in this example: coding issue
    In this case I have found a way to avoid this but just by chance *wink* , not because I knew the reason of the problem *huh* ...
    Jarredja *wink* points out the same behaviour in here ...

    Krpano script mysteries *g* ...

    SAlut...

  • Hi,

    I'm now not sure what's the problem exactly here,
    but I have seen dynamical url changing was used - in the current version there is still a small bug here, in combination with the usage of the onover,onhover or onout events, this will be fixed in the next version,

    but there should be no alignment or zorder problems,
    (a note about the zorder - the internal z-indices will be sorted on each change of the zorder attribute or when the loading of a element has been finished and it was added to the screen),

    but if you had a small example with such problem, I would be happy for it and will try it fix it of course,

    best regards,
    Klaus

  • Hi,

    I'm now not sure what's the problem exactly here,
    but I have seen dynamical url changing was used - in the current version there is still a small bug here, in combination with the usage of the onover,onhover or onout events, this will be fixed in the next version,

    cant wait for the next version... any specific date Klaus ? any hint about new / add on feature? *thumbsup* *w00t*

  • Update: This was solved by Klaus in another post. The cause of the Flash error when deleting hotspots (manually or automatically by krpano upon loading a new panorama), was that I had assigned "STAGE" as the parent of my hotspots. Never do that! STAGE is a very bad parent, at least to hotspots it is.

    I commented on the wrong post. Even though it is correct what I just wrote, it does not apply to this post. *rolleyes*
    Here the two solutions that worked were (1) to use scale9grid as suggested by Michel, or otherwise (2) to recreate the map plugin as suggested by Tuur.

    - Ronny D'Hoore

    Edited 2 times, last by rdhoore108 (October 2, 2010 at 11:05 AM).

Participate now!

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