wait between buttonpresses

  • Hi,

    I'm busy with a interface for krpano, and I got the following problem. The interface consists of several buttons (within flash), when one of them is pressed, it loads a panorama. Easy. Now, the buttons have a active state and turn red when pressed as a way to show the user which panorama he is viewing atm. Now here's the problem, when you press a button it does a call to krpano to load the panorama, and the button turns red, however if you immediately press another button, It turns that button red, but because the pano was busy loading, it didnt receive the call to change the panorama. Especially when you spammclick all the buttons. My goal is to make it idiotproof.

    So I was thinking of disabling the interface plugin (enabled = false) from every mouseclick untill the load is completed.

    However I use tiles, and from the sample flash plugin I understand its hard to calculate the total filesize of all the tiles. So I then thought, Lets disable the interface for one second after each click. But this feels wrong too. The time krpano needs to progress a call is dependend on cpu, so 1 sec wouldnt be enough, but waiting 3secs for any user input could be to extreme.

    How would you solve this? The correct solution would be changing the color of the button after the panorama progressed the first call and is ready to receive more calls (not nesescary after its done, for instance a user wants to go to panorama1 but accidently presses nr2. He realises this and presses panorama1 again, this would lead in panorama2 being loaded but button1 on red). Is this possible? Or perhaps another solution?

  • Hi,

    this is a big and complex topic (especially because of the multi resolution loading),

    solving this at the moment will be very difficult and complex,
    after a xml was loaded, krpano is ready for a new loadpano() call,
    it's possible to call a action/set a variable direct after loadpano() to check this,
    checking "progress.loaddone" isn't allways good, especially for multiresolution,
    (e.g. when zooming in and new tiles were loaded, loaddone is set to false again)
    a solution could be to save and check the state of "progress.loaddone" until it was
    changed the first time, but that's not a good solution...

    I've planned to add new events in the next version,
    e.g.
    "onxmlcomplete" - when the xml was loaded, and krpano is ready for new loadpano calls
    "onviewcomplete" - when the loading of the current view was done, can be used for multiresolution panoramas,
    "onloadcomplete" - when loading of the whole panorama was complete (for normal panoramas)

    and maybe some more events...
    then it should be easier...

    best regards,
    Klaus

  • Now that my debugmode is fixed and you added some new events to 1.08 beta 6, I've been busy optimizing my buttons.

    When I look at the debugmode trace log when I click some buttons rapidly. I get this warning:

    Quote

    WARNING: loadpano() - busy

    This is basicly the Event I need to make my buttons work correctly. Basicly my panorama changing function is:

    Code
    public function ChangePanorama(nextlocation:String):void
    		{
    			var LocationToLoad:String = nextlocation + "_" + Project.currentTrack;				
    			krpano.trace(krpano_as3_interface.DEBUG, "Location to Load: " + LocationToLoad)
    			krpano.call("loadpano(" + LocationToLoad + ".xml, null,MERGE,BLEND(1));"); //Make the call, executing the new pano
    			SetActive();
    		}


    A button activates the ChangePanorama function and sends a string, Based on that string, a location gets loaded. After the krpano call It activates SetActive. The SetActive function loops all the buttons it has in its array checking the name with the LocationToLoad. If it matches it turns the button red, if it doesnt match it turns the button blue.

    Now this works fine. However. If you press the buttons too fast after each other (like 5 secs). The button goes red but krpano will fire loadpano() - busy. Resulting in button 1 being red but panorama 3 loaded. IOW The plugin reacts faster then krpano can handle.

    My idea would be either let krpano send an event when onpreviewcomplete triggers, to flash with an action that executes SetActive.

    Code
    <events onpreviewcomplete="events.setactive()"
     	/>


    Or perhaps a timer in flash that checks every 500ms when krpano.get(onpreviewcomplete) triggers and then checks the stored LocationTo'Load

    Any ideas how I could handle this best? I like to do it with as few xml as possible, and if possible no (performance hit) timers.

  • Hi,

    yes, with the "onpreviewcomplete" it could work,
    but assign the "onpreviewcomplete" event direct with a function from as3
    would be better and faster, when it was set in the xml, it was ordered into a commandqueue,
    and executed, which will be lit bit slower,
    e.g.:

    AS3:

    Code
    krpano.set("events.onpreviewcomplete", my_onpreviewcomplete);
    
    
    ...
    
    
    public function my_onpreviewcomplete():void
    {
    ...
    }

    best regards,
    Klaus

  • Hi,

    in as3 I would assign this event direct in the startup code of the plugin with:

    Code
    krpano = krpano_as3_interface.getInstance();
    krpano.set("events.onpreviewcomplete", my_onpreviewcomplete);

    and then control any further direct from the my_onpreviewcomplete function,

    the "inline" version would be "events.onpreviewcomplete"

    best regards,
    Klaus

Participate now!

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