Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

1

Montag, 26. Januar 2009, 16:01

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.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var LoadingTimer:Timer = new Timer(1000.0/30.0,0); //does a check every 1/30 sec
LoadingTimer.addEventListener(TimerEvent.TIMER, Loading_update); 
LoadingTimer.start();

function Loading_update(timerevent:TimerEvent):void
{
	if ( krpano.get("progress.loaddone") == "false" )
	{
		krpano.set("plugin[gui].enabled", false);
	}
	else
	{
		krpano.set("plugin[gui].enabled", true);
	}
}


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?

2

Dienstag, 27. Januar 2009, 22:49

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

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

3

Mittwoch, 25. Februar 2009, 15:38

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:

Zitat

WARNING: loadpano() - busy
This is basicly the Event I need to make my buttons work correctly. Basicly my panorama changing function is:

Quellcode

1
2
3
4
5
6
7
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.

Quellcode

1
2
	<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.

4

Mittwoch, 25. Februar 2009, 22:27

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:

Quellcode

1
2
3
4
5
6
7
8
krpano.set("events.onpreviewcomplete", my_onpreviewcomplete);

...

public function my_onpreviewcomplete():void
{
...
}


best regards,
Klaus

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

5

Montag, 2. März 2009, 12:49

when would you set the event in as3? Before or after the loadpano call? Because it seems the event is triggered immediately.

Is there a inline version of it? like view.fov=90&onpreviewcomplete="setactive"

6

Dienstag, 3. März 2009, 00:07

Hi,

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

Quellcode

1
2
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