Hi! Thanks for your interest.
(EDIT: I am not using scenes.)
I can't show you all of my xml or link to it because it's generated on the fly using php. The history buttons I was using were pretty much copied straight from your number 1 xml file - the delete, new, back and forward actions and the button plugins, as well as the call to new onxmlcomplete of course. I tried messing around with your code and even rewrite it, but I soon got pissed at how limited and weird the if command is (it kept getting ignored when the condition contained certain constructs, for no apparent reason) so I decided to write my history manager as a plugin. Here it is:
|
Source code
|
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import krpano_as3_interface;
var krpano:krpano_as3_interface;
var plugin:Object;
var history:Array = new Array();
var position:Number = -1;
stop();
if (stage == null) {
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
function startplugin(event:Event):void {
krpano = krpano_as3_interface.getInstance();
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
}
function stopplugin(event:Event):void {
krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
krpano = null;
}
function registerEvent(evt:DataEvent):void {
var path:String = evt.data;
plugin = krpano.get(path);
plugin.register = update;
plugin.back = prev;
plugin.forward = fw;
if (!plugin.hasOwnProperty("backbutton")) plugin.backbutton = null;
if (!plugin.hasOwnProperty("fwbutton")) plugin.fwbutton = null;
}
function update(place:String):void {
if (history.length < 1 || history[position] != place) {
if (history.length > 0)
history = history.slice(0, position+1);
history.push(place);
position = history.length - 1;
if (plugin.fwbutton != null)
krpano.set("plugin[" + plugin.fwbutton + "].visible", false);
if (plugin.backbutton != null && position > 0)
krpano.set("plugin[" + plugin.backbutton + "].visible", true);
}
}
function prev():void {
if (position > 0) {
position -= 1;
krpano.call("loadpano(" + history[position] + ",null,MERGE,BLEND(2));");
if (plugin.backbutton != null && position == 0)
krpano.set("plugin[" + plugin.backbutton + "].visible", false);
if (plugin.fwbutton != null)
krpano.set("plugin[" + plugin.fwbutton + "].visible", true);
}
}
function fw():void {
if (position < history.length - 1) {
position += 1;
krpano.call("loadpano(" + history[position] + ",null,MERGE,BLEND(2));");
if (plugin.fwbutton != null && position == history.length - 1)
krpano.set("plugin[" + plugin.fwbutton + "].visible", false);
if (plugin.backbutton != null)
krpano.set("plugin[" + plugin.backbutton + "].visible", true);
}
}
|
How to use:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<plugin name="history" url="history.swf" backbutton="back_button" fwbutton="forward_button" keep="true" preload="true" />
<events onxmlcomplete="plugin[history].register(get(my.filename));" />
<plugin name="back_button"
url="prev.png"
keep="true"
visible="false"
onclick="plugin[history].back();" />
<plugin name="forward_button"
url="next.png"
keep="true"
visible="false"
onclick="plugin[history].forward();" />
|
You must customize the buttons to taste and you can also change the plugin itself to add tweens and other stuff. Passing the button names to the plugin is optional and only needed if you want it to control the visibility of said buttons. my.filename contains the XML filename; Since xml.url is borked on my site I created my own filename field which is filled on the fly by php, but you can replace my.filename with xml.url if xml.url works for you.