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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
package
{
import flash.display.*;
import flash.events.*;
import flash.system.*;
import flash.net.*;
import flash.filters.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
import flash.xml.*;
import flash.ui.Mouse;
import krpano_as3_interface;
public class krpano_embed extends Sprite
{
public var krpano:krpano_as3_interface = null;
public var krpanoloader:Loader = new Loader();
public function krpano_embed()
{
krpanoloader.contentLoaderInfo.addEventListener(Event.COMPLETE, krpano_load_complete);
krpanoloader.load(new URLRequest("krpano.swf"));
}
public function krpano_load_complete(event:Event):void
{
event.target.content as Object.embeddedstartup(stage, krpano_ready);
}
public function krpano_ready(krpanointerface:krpano_as3_interface):void
{
krpano = krpanointerface;
// open the krpano log and show a message:
krpano.call("showlog(true);");
krpano.trace(0,"ready...");
// load a inline xml with a preview image as demo
krpano.call("loadxml('<preview type="grid(cube);" />');");
// load a pano xml:
// krpano.call("loadpano(pano.xml,null,MERGE,BLEND(1));");
// get notified about krpano resizes
krpano.set("events.onresize", krpano_resize_event);
// change the pano area to a fixed size:
var area:Object = krpano.get("area");
area.x = 20;
area.y = 20;
area.width = 400;
area.height = 300;
// examples how to add/change plugins from as3:
// 1. the "set-interface" way:
krpano.call("addplugin(button1);");
krpano.set("plugin[button1].url", "button.jpg");
krpano.set("plugin[button1].parent", "STAGE");
krpano.set("plugin[button1].align", "righttop");
krpano.set("plugin[button1].x", 10);
krpano.set("plugin[button1].y", 10);
krpano.set("plugin[button1].onhover", "showtext(toggle pano layer);");
krpano.set("plugin[button1].onclick", toggle_krpano_visibilty);
// 2. the direct object way (faster)
krpano.call("addplugin(button2);");
var button2:Object = krpano.get("plugin[button2]");
button2.url = "button.jpg";
button2.parent = "STAGE";
button2.align = "righttop";
button2.x = 10;
button2.y = 50;
button2.onhover = "showtext(change area size);";
button2.onclick = toggle_krpano_area;
}
public function krpano_resize_event():void
{
var area:Object = krpano.get("area");
krpano.trace(0,"pano resize - pos=" + area.pixelx + "," + area.pixely + " size=" + area.pixelwidth + "x" + area.pixelheight);
}
public function toggle_krpano_visibilty():void
{
var imagelayer:Sprite = krpano.get("image.layer");
if (imagelayer.visible == true)
{
imagelayer.visible = false;
}
else
{
imagelayer.visible = true;
}// toggle also the plugin layer
krpano.set("plugin.visible", imagelayer.visible);
}
public function toggle_krpano_area():void
{
var area:Object = krpano.get("area");
// just toggle between two sizes
if (area.x == 20)
{
area.x = 0;
area.y = 0;
area.width = "100%";
area.height = "100%";
}
else
{
area.x = 20;
area.y = 20;
area.width = 400;
area.height = 300;
}
}
}
}
|