Sie sind nicht angemeldet.

1

Dienstag, 18. November 2008, 21:06

Error with loadpano

I built a simple plugin that registers a click on a box and calls krpano.call("action(load2)"). If the function in the action is loadpano(pano2.xml), I get this:

Quellcode

1
2
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at krpano::krpano_plugin/event_click()

when it loads the new pano even though when this action is called by a hotspot I don't get the error. If I change the function in the load2 action to delayedcall(0,loadpano(pano2.xml)) I don't get an error. Any idea as to what might be going on? I am baffled.
Thanks

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »marcbn« (18. November 2008, 21:45)


2

Dienstag, 18. November 2008, 21:54

Hi,

can you post the code how you registered the click,
or a link to a online example?

best regards,
Klaus

3

Dienstag, 18. November 2008, 22:12

Here is the event listener, I tried both; I thought maybe I should be using the addPluginEventListener instead:

Quellcode

1
2
3
		button.addEventListener(MouseEvent.CLICK,pluginClick);
//krpano.addPluginEventListener(button,MouseEvent.CLICK,pluginClick);
	

and the pluginClick function:

Quellcode

1
2
3
function pluginClick(e:Event) {
	krpano.call("action(load2)");
}

and the XML:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?xml version="1.0" encoding="utf-8"?>
<krpano version="1.0.7">
	<plugin name="testPlugin" url="testPlugin.swf" />
	<action name="load1">
		loadpano(krpano.xml)
	</action>
	<action name="load2">
		loadpano(pano2.xml)
		<!--delayedcall(0,loadpano(pano2.xml))-->
	</action>
	<action name="load3">
		loadpano(pano3.xml)
	</action>
	<image type="CUBE">
		<left url="panos/385_1/_l.jpg" />
		<front url="panos/385_1/_f.jpg" />
		<right url="panos/385_1/_r.jpg" />
		<back url="panos/385_1/_b.jpg" />
		<up url="panos/385_1/_u.jpg" />
		<down url="panos/385_1/_d.jpg" />
	</image>
	<hotspot name="pano1to2" onhover="showtext(Bridge)" onclick="action(load2)">
		<point ath="135" atv="-5" />
		<point ath="150" atv="-5" />
		<point ath="150" atv="+5" />
		<point ath="135" atv="+5" />
	</hotspot>
	<hotspot name="pano1to3" onhover="showtext(Dock)" onclick="action(load3)">
		<point ath="205" atv="-5" />
		<point ath="215" atv="-5" />
		<point ath="215" atv="+5" />
		<point ath="205" atv="+5" />
	</hotspot>
</krpano>

4

Dienstag, 18. November 2008, 23:40

this code is okay:

Quellcode

1
button.addEventListener(MouseEvent.CLICK,pluginClick);

addPluginEventListener is only for special plugin events (REGISTER,RESIZE,UPDATE)

this code is okay too:

Quellcode

1
2
3
function pluginClick(e:Event) {
krpano.call("action(load2)");
}


normally it should work...

one question - was the "krpano" interface already set?

Quellcode

1
krpano = krpano_as3_interface.getInstance();


EDIT - once more - does this error appear only on the second click?
please try to set the "keep" attribute of your plugin to "true" to be sure that the plugin is not unloaded when loading a other pano,

Quellcode

1
<plugin name="testPlugin" url="testPlugin.swf" keep="true" />


best regards,
Klaus

5

Dienstag, 18. November 2008, 23:50

Adding keep="true" did the trick, thank you very much.