You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 994

Location: Netherlands

Occupation: Web developer

  • Send private message

1

Monday, January 26th 2009, 4:01pm

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.

Source code

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?
3d childrens game using krpano Game
Minify your xml with my krpano XML Compressor
Krpano XML Parsing Error Checklist
Available for hire (krpano xml, javascript, actionscript, flash, php and ipad plugins).

2

Tuesday, January 27th 2009, 10:49pm

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

Professional

  • "Zephyr" started this thread

Posts: 994

Location: Netherlands

Occupation: Web developer

  • Send private message

3

Wednesday, February 25th 2009, 3:38pm

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:

Quoted

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

Source code

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.

Source code

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.
3d childrens game using krpano Game
Minify your xml with my krpano XML Compressor
Krpano XML Parsing Error Checklist
Available for hire (krpano xml, javascript, actionscript, flash, php and ipad plugins).

4

Wednesday, February 25th 2009, 10:27pm

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:

Source code

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

...

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


best regards,
Klaus

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 994

Location: Netherlands

Occupation: Web developer

  • Send private message

5

Monday, March 2nd 2009, 12:49pm

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"
3d childrens game using krpano Game
Minify your xml with my krpano XML Compressor
Krpano XML Parsing Error Checklist
Available for hire (krpano xml, javascript, actionscript, flash, php and ipad plugins).

6

Tuesday, March 3rd 2009, 12:07am

Hi,

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

Source code

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