News Examples Documentation Download Buy Forum Contact
NOTE: This page is from an older version, see the latest version here.

krpano Actions / Scripting Reference Version 1.0.8.12

krpano has a small and simple dynamic scripting language. With it krpano can be customized in many ways. A command or function is called action in krpano. It's possible to use existing actions and also to define new ones. The script language is dynamic and basically untyped, only some predefined variables are typed, but that's not important, inside the script any type conversion will be done automatically.

About this documentation

This documentation is about the krpano xml structure, about all xml nodes and about all attributes and values and their mapping to their dynamic krpano variable names.

Documentation topics:

krpano Global variables reference

Version / Build information Screen information / settings Device information Mouse / Keyboard Timing / Random values Keyboard / Button moving Multiresolution information XML / Scene Debugging / Error handling Layers

krpano Actions / Functions reference

Programming logic / Flow control Math operators Number / String formating Animations / Animated value changing Dynamic loading of other panos (tours) Viewing animations / Camera control Coordinate transformation Text visualization View / Pano updates Dynamic adding or removing of visible elements Plugin / Hotspot Actions External / Javascript Interface Debugging

Syntax and usage

The calling conventions of krpano actions / functions:

action-name(parameters);
  • The action-name can be the name of a predefined krpano action or the name of an <action> node that was defined anywhere in the xml.
  • It's possible to call severals actions at once, just end each action with a semicolon ;.
  • The actions will be processed one after the other.
  • 'White'-spaces (like spaces, tabs and new lines) between action calls and between parameters will be ignored.
  • The number of parameters to use depend on the called action.
  • The parameters must be separated by commas ,.
  • To be able to use white-spaces and commas in a parameter the parameter must be enclosed by single quotes ' or by double quotes ".
  • The given parameters are passed as texts to the action. When the text of the parameter is the name of a variable then the variable will not be automatically resolved to its value! Some actions are resolving variables automatically but this depends on the action itself. To force resolving a variable and passing only the content/value of a variable use the get action.
  • Have also a look to this great and very detailed explanations from pinsane about the krpano actions and their arguments/parameters in the krpano forum.

Detail documentations

Global variables
here are the detail documentations about the krpano global variables:
variable name (read only)typedefault value
version String
The krpano version string, e.g. "1.0.8.12".
variable name (read only)typedefault value
xmlversion String
The version setting from the xml. When not set this will be the same number as the krpano version string.
variable name (read only)typedefault value
build String
The krpano build string, e.g. "2010-10-22".
variable names (read only)typedefault value
mouse.x
mouse.y
mouse.stagex
mouse.stagey
int
int
int
int
The current mouse position.
The mouse.x and mouse.y coordinates are relative to the left top edge of the area and the mouse.stagex and mouse.stagey coordinates to the left top edge of the whole flash stage/window.
variable name (read only)typedefault value
keycode int
The keycode of the last pressed or released key.
It will be set in the onkeydown and onkeyup events.

Note - here a small code snippet to find out the keycode of each key:
<events onkeydown="showlog(); trace('keycode=',keycode);" />
variable name (read only)typedefault value
wheeldelta int
The delta of the mouse wheel rotation.
This variable will be set in the onmousewheel event.
variable nametypedefault value
fullscreen Boolean false
The fullscreen variable holds the current state of the fullscreen mode.
When it will be changed, then also the fullscreen mode will change.

Note - there is a Flashplayer security limitation - switching to fullscreen mode is only possible as reaction of an user input like a mouse click or a keypress! That means you can only switch to fullscreen mode in a onclick or onkeydown event.

Example - switch to fullscreen mode:
... onclick="set(fullscreen,true);"
Example - switch between fullscreen and windowed mode:
... onclick="switch(fullscreen);"
variable names (read only)typedefault value
stagewidth
stageheight
int
int
The size of the current window in pixels.
Get the this size in the onresize event.
variable names (read only)typedefault value
isphone
ispad
isandroid
isflash
ishtml5
Boolean
Boolean
Boolean
Boolean
Boolean
Device detection variables. Check them with the if action.
  • isphone - true only on the iPhone 3/4 (and iPod Touch)
  • ispad - true only on the iPad
  • android - true only on a Android device
  • flash - true only in the Flashplayer (Desktop and Android)
  • html5 - true only in the krpanoJS (HTML5) viewer
variable name (read only)typedefault value
timertick int
The timertick variable returns the number of milliseconds that have elapsed since the viewer was started (1000 milliseconds = 1 second).
variable name (read only)typedefault value
random Number 0.0 - 1.0
The random variable returns the a random number in range 0.0 to 1.0.

Example - how to get a random value in the range 1 - 10:
mul(val, random, 9);
add(val, 1);
roundval(val);
trace('random value=',val);
variable namestypedefault value
hlookat_moveforce
vlookat_moveforce
fov_moveforce
Number
Number
Number
0.0
0.0
0.0
These variables are defining a moving force to move the view / the pano.

When set to a value other than 0.0 the view will start slowly accelerating (controlled by keybaccelerate) and move with a maximum speed (controlled by keybspeed) until set back to 0.0, then it will slow down (controlled by keybfriction).
variable name (read only)typedefault value
multireslevel int
The multireslevel variable returns the current multi-resolution level
(0 - image.level.count).
variable nametypedefault value
lockmultireslevel String -1
Lock the automatic multi-resolution level selection to a fixed level.
Set lockmultireslevel to "current" to lock the level to the current level. To release the level locking set lockmultireslevel back to "-1".
variable nametypedefault value
downloadlockedlevel Boolean false
When set to true then the locked level will be downloaded completely.
variable name (read only)typedefault value
xml.url String
The xml.url variable contains the path/url of the currently loaded xml file.
variable name (read only)typedefault value
xml.content String
The xml.content variable contains the whole content of the currently loaded xml file as string.
variable name (read only)typedefault value
xml.scene String
The xml.scene variable contains the name of currently loaded scene.
variable name (read only)typedefault value
lasterror String
The lasterror variable contains the last error message when an error had happened. To get this variable the onloaderror event must be used.
variable name (read only)typedefault value
haveexternalinterface Boolean true
This variable can be used to check if the External Interface from the Flashplayer is available. This interface is nesecery for the Javascript Interface, for the openurl action and when using plugins (like the googlemaps plugin) that load code/data from the web.

Online on a server the External Interface is always available, but locally only when the folder of the Flash swf is in a 'trusted folder'. The trusted folders can be managent in the Flashplayer security settings, see here for more detatils - Local / Offline Usage.


Actions detail documentations

set(variable,value)
Set the "variable" to "value".

Note - when "value" is also variable, it will not be resolved automatically! To set the content of a other variable to the current variable the get function must be used for it.

Parameters:
  • variable
    Any variable.
    When the variable doesn't exists it will be created.
  • value
    The new value for this variable.
Examples
set(var1,'hello');
set(var2,get(var1));
set(fullscreen,true);
set(plugin[p1].visible,false);
set(hotspot[h1].scale,2.5);
set(contextmenu.item[0].caption,'hello item');
set(events.onxmlcomplete,null);
get(variable)
Resolves the "variable" to its value.

The get(var) action can be only used as parameter when calling an other action or inside an array access [ ] operator!

Note - some actions automatically try to resolve given parameters to their value, there using get is not necessary!

Parameters:
  • variable
    Any variable.
    When the variable doesn't exists it will return null.
Examples
set(dstvar,get(srcvar));
looktohotspot(get(name));
lookto(get(h),get(v),get(f));
showtext(get(msg));
tween(var,get(dstval));
set(pic, spot1);
set(hotspot[get(pic)].visible,false);
trace('xyz=',xyz,' get(xyz)=',get(xyz));
txtadd(msg,'fov=',get(view.fov));
copy(destination,source)
The copy action copies the content from one variable to the other one.
(This is the same like "set(destination,get(source));")

Parameters:
  • destination
    The destination variable.
    When the variable doesn't exists it will be created.
  • source
    The source variable.
    When the variable doesn't exists null will be set to the destination variable.
Examples
copy(dstvar,srcvar);
copy(cur_hlookat,view.hlookat);
copy(plugin[text].x, mouse.x);
copy(plugin[text].y, mouse.y);
if(condition, then-actions, else-actions*)
ifnot(condition, then-actions, else-actions*)
The if action allows a conditional execution of code.
If actions can be nested infinitely within other if actions, this provides a complete flexibility for conditional code execution.

Parameters:
  • condition - the condition to check
    When the result of the condition is true, then the then-actions will be executed, and when the condition is false, then the else-actions.

    There are two types of conditions possible:
    1. Checking one variable:
      if(variable, ...);
      This variable will be compared against true.
      Should be used to check boolean true/false variables.

    2. Comparing two variables or values:
      if(var1 OPERATOR var2, ...);
      The var1 or var2 can be a variables or values. When var1 or var2 is a variable then the content of the variable will be used for comparison. Only when using a 'strict' comparison operator (=== or !==) then var1 and var2 must be variables (or null).

      Available operators:
      • "==" - equal
      • "!=" - not equal
      • "<" or "LT" - lower than *
      • ">" or "GT" - greater than *
      • "<=" or "LE" - lower or equal than *
      • ">=" or "GE" - greater or equal than *
      • "===" - strict equal (compare only existent variables)
      • "!==" - strict not equal (compare only existent variables)
      * Note - because of the xml format limitation of the usage of the '<' and '>' characters is not possible every time!

  • then-actions
    The krpano actions that will be executed when the condition is true.

  • else-actions (optionally)
    The krpano actions that will be executed when the condition is false.

Notes - about the then/else actions - there can be several actions, not only one! Each action command must end with a semicolon then the next action command can follow!
Examples
if(fullscreen, fullscreensetup(), windowsetup() );
if(fullscreen, set(plugin[controls].visible, false) );
if(%1 != next, set(i,0) );
if(i LT 10, loop(next) );
if(var === null, set(var,0));
if(hotspot[spot1] === null, trace(there is no spot1 hotspot));
if(varA GT 5,
    if(varA LT 10,
        trace('varA is between 5 and 10')
      );
  );
set(result,true);
ifnot(varA, set(result,false) );
ifnot(varB, set(result,false) );
ifnot(varC, set(result,false) );
if(result, trace('all vars are true') );
if(var1 GT var2,
    trace('condition is true');
    lookto(100,20,50);
  ,
    trace('condition is false');
    lookto(0,0,100);
  );
action(actionname,parameters*)
or simply:
actionname(parameters*)
Calls an <action> with parameters and executes the action commands that are defined in it.

Note - an action can be called 'direct' without using the action() command, just use the name of the action!

Parameters:
  • actionname
    The name of the action. When there is no action with that name there will be a warning in the trace log.

  • parameters (optionally)
    Optional parameters for the action.

    To use this parameters inside the action there are placeholders in the form %0 - %99. Where %0 is the name of the action, %1 the first parameter, %2 the second one and so on. The parameter passing works via simple text replacing. That means before the code in an action will be executed all placeholders will be replaced by their given parameters. A placeholder without a given parameters will be replaced by 'null'.

    Use quotes like 'parameter' or "parameter" to mark everything between the quotes as a "connected string". This allows the usage of commas (,) and blanks in a parameter.
Examples
<krpano onstart="intro();">
  ...
  <action name="intro">
    lookat(0,0,90);
    wait(LOAD);
    lookto(120,10,110);
    lookto(-50,40,110);
    lookto(0,0,90);
  </action>
  ...
</krpano>

<action name="overaction">
  tween(scale, 2.0);
  tween(alpha, 1.0);
</action>

<action name="outaction">
  tween(scale, 1.0);
  tween(alpha, 0.5);
</action>

<plugin name="pic1" ...
        onover="overaction();"
        onout="outaction();"
        />

<plugin name="pic2" ...
        onover="overaction();"
        onout="outaction();"
        />

<action name="test">
  showlog();
  trace('parameter1=',%1);
  trace('parameter2=',%2);
</action>

<action name="parameterpassingtest">
  test('Test1', 'Test2');
</action>
delayedcall(delay,actions)
Calls / executes the given actions after a given time.

Parameters:
  • delay
    The number of seconds to wait before executing the actions.
  • actions
    The action commands to execute.
Examples
delayedcall(5.0, hidelogo() );
delayedcall(10, looktohotspot(spot1);loadpano(pano2.xml); );
delayedcall(1, showtext('hello');       );
delayedcall(4, showtext('to the pano'); );
<action name="updatemousepos">
  copy(plugin[cursor].x, mouse.x);
  copy(plugin[cursor].y, mouse.y);
  delayedcall(0.02, updatemousepos() );
</action>
switch(variable,valueA*,valueB*,...)
The switch action switches the value of the given variable between / through several states. Everytime when the switch action will be called the value will be switched / changed.
When only the variable itself without value parameters will be given, then the variable will be switched between true and false.
When there are 2 or more values given as parameters then the variable will switch through all of these values.

Parameters:
  • variable
    The variable that should be switched/changed.
  • valueA / valueB / ... (optionally)
    The values for this variable.
Examples
switch(fullscreen);
switch(hotspot.visible);
switch(plugin[button1].visible);
switch(plugin[button1].alpha, 1.0, 0.5);
switch(plugin[child].parent, button1, button2, button3);
switch(destpos, -100, 0, +100); tween(y,get(destpos));
push(variable)
pop(variable)
push - saves/pushes the value of the variable to the stack.
pop - restores/pops the value from the stack and saves it into the variable.

The stack is based on the principle of Last In First Out (LIFO).

Parameters:
  • variable
    Any variable.
Examples
push(varA);
push(varB);
pop(varB2);
pop(varA2);
push(plugin[%1].width);
push(plugin[%1].height);
plugin[%1].resetsize();
copy(plugin[%1].originalwidth, plugin[%1].width);
copy(plugin[%1].originalheight, plugin[%1].height);
pop(plugin[%1].height);
pop(plugin[%1].width);
stopall()
  • Stops / breaks all current running actions / tweens.
  • Removes the rest of the queued actions.
breakall()
  • Stops / breaks all current running actions / tweens.
  • Continues with the rest of the queued actions.
add(variable,valueA,valueB*)
sub(variable,valueA,valueB*)
mul(variable,valueA,valueB*)
div(variable,valueA,valueB*)
mod(variable,valueA,valueB*)
pow(variable,valueA,valueB*)
Actions for mathematical calculations.
These actions can be used with 2 or 3 parameters:

  • with 2 parameters:
    • add(dst,val1)  ⇒  dst = dst + val1 (like +=)
    • sub(dst,val1)  ⇒  dst = dst - val1 (like -=)
    • mul(dst,val1)  ⇒  dst = dst * val1 (like *=)
    • div(dst,val1)  ⇒  dst = dst / val1 (like /=)
    • mod(dst,val1)  ⇒  dst = dst % val1 (modulate)
    • pow(dst,val1)  ⇒  dst = dst ^ val1
  • with 3 parameters:
    • add(dst,val1,val2)  ⇒  dst = val1 + val2
    • sub(dst,val1,val2)  ⇒  dst = val1 - val2
    • mul(dst,val1,val2)  ⇒  dst = val1 * val2
    • div(dst,val1,val2)  ⇒  dst = val1 / val2
    • mod(dst,val1,val2)  ⇒  dst = val1 % val2 (modulate)
    • pow(dst,val1,val2)  ⇒  dst = val1 ^ val2

Note - val1/val2 can be values or variables. When val1 or val2 is a variable then automatically the content of the variable will be used!

Parameters:
  • variable
    The variable where the result of the calculation will be stored.
    When the variable doesn't exists it will be created.
  • valueA / valueB (optionally)
    The values or variables for the calculation.
Examples
set(val, 1);
add(val, 1);
trace('val should be 2: val=',val);
mul(doublewidth, width, 2.0);
mul(scale, 0.5);
div(result, vala, valb);
add(dst,rotate,360); tween(rotate,get(dst),5);
add(xpos, mouse.x, mouse_x_offset);
sub(destx, stagewidth,  destwidth);
div(aspect,16,9);
mod(cur_hlookat,cur_hlookat,360);
pow(sqrt,val,0.5);
inc(variable,byvalue*,max*,min*)
dec(variable,byvalue*,min*,max*)
These actions increase or decrease values (with saturation). - byvalue - add/sub this value to the var, default=1 - max - max limit, when reaching it, the var will be set to min - min - min limit, when reaching it, the var will be set to max

Parameters:
  • variable
    The variable to increase or decrease.
  • byvalue (optionally)
    Increase or decrease the variable by this value. When not set the variable will be increase or decrease by 1.
  • max / min (optionally)
    Defines maximum and minimum values, when one limit will be reached then the value will be set back to the other limit value. This can be used to let the varibale wrap around a defined range or to clip at at specific limit (with min=max).
Examples
inc(i);
inc(frame,1,get(lastframe),0);
inc(ypos,30);
inc(view.hlookat, 2, 90, 90);
roundval(variable,decimalplaces*)
Rounds the value of the variable to given decimal places (0 when not set).
(Note - the variable will be a string internally after rounding)

Parameters:
  • variable
    The variable to be rounded.
  • decimalplaces (optionally)
    The number of decimal places.
Examples
roundval(val);
roundval(val,2);
copy(cur_hlookat,view.hlookat);
mod(cur_hlookat,360);
roundval(cur_hlookat,2);
copy(cur_vlookat,view.vlookat);
roundval(cur_vlookat,2);
txtadd(msg,'looking at ',get(cur_hlookat),'/',get(cur_vlookat));
txtadd(destination,txt1,txt2*,txt3*,...*)
The txtadd action can be used to connect several texts / values together.
The action can be used with 2 or more parameters. When using only two parameters (destination and a text) then the text will be added to current value of the destination variable.

Parameters:
  • destination
    The destination variable where the connected text will be stored.
    When the variable doesn't exists it will be created.
  • txt1, txt2, txt3, ... (optionally)
    The texts that will be connected together. When using only one txt parameter then this text will be added to the content of current destination variable.
    Note - when the conntet of a variable should be used then the get() action must be used to resolve the variable!
Examples
txtadd(picfilename,'%CURRENTXML%/pic_',get(pic),'.jpg');
txtadd(crop,'0|',get(ypos),'|333|285');
txtadd(pname, 'thumbbar_image_', get(i));
txtadd(plugin[text].html,'[p]',get(data[txt1].content),'[/p]');
txtadd(msg,get(view.fovtype),'=',get(fov),'°');
tween(variable,destinationvalue,time*,tweentype*,donecall*)
The tween action can be used for a time controlled animation / change of a variable.
The action will dynamically change the current value of the variable to the given destination value. And this will be done within the given time (0.5 seconds by default). With the tweentype parameter the form of the interpolation change be changed. When the tween was done and the value of the variable has reached the destination value then the donecall actions will be called / executed.

Parameters:
  • variable
    The variable that should be changed.
  • destinationvalue
    The destination value for this variable.
    When tweening percent values add a '%' character to the value.
    Note - to tween to the value of another variable use the get() action to get the value of the other value!
  • time (optionally)
    • The time in seconds for the change from the current value to the destination value (0.5 seconds by default).
    • Instead of using a fixed time for the change it is possible to define the maximum moving distance for the value and a time for that distance.
      This allows to use a short time for a short distance and long time for a long distance. This can be done by using the distance function:

      distance(maxdistance,maxtime)
      • maxdistance - the maximum distance between the start and the destination value
      • maxtime - the time in seconds for this maximum distance
  • tweentype (optionally)
    The interpolation type (easeOutQuad by default)
    See here for all available tween types: tweentypes.
  • donecall (optionally)
    The action commands to execute when the destination value has been reached.
    Instead of some actions it is also possible to use special keyword WAIT, in this case the user interface and the execution of the following actions will be blocked until the destination values has been reached.

Some information about the origin of the name "tween" - Wikipedia about Tweening.
Examples
tween(scale,2);
tween(rotate,90);
tween(width,50%);
onover="tween(alpha,0.7,distance(0.3,0.2));"
onout="tween(alpha,1.0,distance(0.3,0.2));"
set(alpha,0);
set(visible,true);
tween(alpha, 1.0 ,0.3);
tween(plugin[logo].width, get(destwidth));
set(plugin[image].enabled,false);
tween(plugin[image].alpha,0.0,0.5,default,removeplugin(image));
set(view.stereographic,true);
tween(view.vlookat, 90.0, 2.0);				
tween(view.fisheye, 1.0, 2.0);
tween(view.fov, 150.0, 2.0);
stoptween(variable,...)
The stoptween action stops a currently running tween action.

Parameters:
  • variable
    The name of the variable which is currently tweening and should be stopped.
  • ... variable, variable, ... (optionally)
    Addtional variables that should stop tweening.
Examples
ondown="tween(plugin[text].y, 10, distance(400,0.7), linear);"
onup="stoptween(plugin[text].y);"
Here all supported tween types for the tween action.
Linear Ease:
  • linear
Ease Out:
  • easeOutQuad (the default)
  • easeOutQuart
  • easeOutQuint
  • easeOutSine
  • easeOutBounce
  • easeOutCirc
  • easeOutCubic
  • easeOutExpo
Ease In:
  • easeInQuad
  • easeInQuart
  • easeInQuint
  • easeInSine
  • easeInBounce
  • easeInCirc
  • easeInCubic
  • easeInExpo
Ease Out and In:
  • easeOutInQuad
  • easeOutInQuart
  • easeOutInQuint
  • easeOutInSine
  • easeOutInBounce
  • easeOutInCirc
  • easeOutInCubic
  • easeOutInExpo
Ease In and Out:
  • easeInOutQuad
  • easeInOutQuart
  • easeInOutQuint
  • easeInOutSine
  • easeInOutBounce
  • easeInOutCirc
  • easeInOutCubic
  • easeInOutExpo
Advanced ease function with optional parameters:
  • easeInElastic(amplitude*,period*)
  • easeOutElastic(amplitude*,period*)
  • easeInBack(overshoot*)
  • easeOutBack(overshoot*)

Here some online visualization of the different tween types:
http://hosted.zeh.com.br/tweener/docs/en-us/misc/transitions.html
http://hosted.zeh.com.br/mctween/animationtypes.html
loadpano(xmlpath,vars*,flags*,blend*)
loadxml(xmlstring,vars*,flags*,blend*)
loadscene(scenename,vars*,flags*,blend*)
Actions to load a new pano.

Note 1 - only the plugin, hotspot and lensflare elements with keep="true" will be kept when loading a new pano.
Note 2 - when there are additional action commands after the loadpano call then the onstart event of the new loaded pano will not be executed!

Parameters:
  • xmlpath (for loadpano)
    The path/url of the new pano xml file to be loaded (use null for none).
    When a relative path will be used then the file will be loaded from the basedir folder, which is %FIRSTXML% by default. That means that the paths in all loadpano calls are relative to the first loaded xml file.

  • xmlstring (for loadxml)
    The content of a xml file as string/text to be loaded (should be escape-coded).

  • scenename (for loadscene)
    The name of the <scene> to be loaded.

  • vars (optionally)
    Variables to set (use null for none).
    These variables will be set after parsing/resolving the xml but before starting to load. This can be used to overwrite any settings from the xml or to set addtional ones. The variables can be defined as var1=val1 pairs separated by a & character. (e.g. sphere=image.jpg&view.fov=120&view.fisheye=0.35)

  • flags (optionally)
    Addtional flags for loading (use null for none).
    Flags can be combined by a | character.

    Possible flags:
    • MERGE (the recommended flag)
      • Merges all settings from the current and the next pano.
      • If there are plugins and hotspots in the new panorama with the same name as the kept ones, the new elements will not be loaded.
      • This is the recommended setting for virtual tours.
    • KEEPVIEW - keep current view settings
    • KEEPDISPLAY - keep current display settings
    • KEEPCONTROL - keep current control settings
    • KEEPPLUGINS - keep current loaded plugins
    • KEEPHOTSPOTS - keep current loaded hotspots
    • KEEPPROGRESS - keep current progress settings
    • NOPREVIEW - ignore the <preview> tag of the new xml
    • KEEPBASE - a predefined combination of:
      KEEPDISPLAY | KEEPCONTROL | KEEPPLUGINS | KEEPPROGRESS
    • KEEPALL - a predefined combination of:
      KEEPVIEW | KEEPDISPLAY | KEEPCONTROL | KEEPPLUGINS | KEEPPROGRESS
    • IGNOREKEEP - ignore the keep flags and remove also the elements with keep="true"

  • blend (optionally)
    Blend / fade to next panoroma.

    Possible blending modes:
    • NOBLEND = no blending (default).
    • BLEND(n) = blends from current panorama to next in n seconds
    • ZOOMBLEND(n,z) = zooms and blends in n seconds with zoom factor z
Examples
loadpano(pano2.xml);
loadpano(pano2.xml, null, MERGE, BLEND(1));
loadscene(scene1);
loadscene(scene1, null, MERGE, BLEND(1));
loadxml('<krpano><image><sphere url="pano.jpg"/></image></krpano>');
loadxml(get(data[xml].content), null, KEEPALL);
loadpano('%SWFPATH%/pano.xml', null, MERGE, BLEND(2));
loadpano(sphere.xml, image.hfov=1.0&view.limitview=fullrange);
reloadpano()
Reload the current panorama.

The image parameters like "image.sphere.url" or "image.type" can't be changed dynamically. The parsing of these parameters happens only once at loaded, so to get changed images variables working the pano itself must be reloaded. This can done with this action.
openurl(url,target*)
Open an external url.

Note - this action requires the External Interface of the Flashplayer! This means the action will work offline/locally only when the security settings of the Flashplayer were adjusted. See here for more detatils - Local / Offline Usage.

Parameters:
  • url
    The url to open.
  • target (optionally)
    The target where the url should be opened.

    Possible settings:
    • _blank - open the url in a new window (the default)
    • _self - open the url in the current frame in the current window
    • _parent - open the url in the parent of the current frame
    • _top - open the url in the top-level frame in the current window
Examples
openurl('http://krpano.com',_self);
openurl('help.html');
lookat(atH,atV,fov*)
Look at this panorama position.

Parameters:
  • atH
    Horizontal position in degrees, spherical coordinates (-180 to +180).
  • atV
    Vertical position in degrees, spherical coordinates (-90 to +90).
  • fov (optionally)
    The new field of view in degrees (0 - 179).
Examples
lookat(0,0);
lookat(0,0,90);
loadpano(pano.xml); lookat(45.1, -20.2, 110.0);
lookto(toH,toV,fov*,motiontype*,shortestway*)
looktohotspot(hotspotname,fov*,motiontype*,shortestway*)
moveto(toH,toV,motiontype*)
zoomto(fov,motiontype*)
Moves the view from current to the given position.

Note - the user interface and all other actions are blocked during the movement. That means the next action will be executed when the current action was done. The oninterrupt action can be used to make these actions interrupt able by the user.

Parameters:
  • toH
    Horizontal destination looking direction (-180 to +180, wraparound possible).

  • toV
    Vertical destination looking direction (-90 to +90).

  • hotspotname (for looktohotspot)
    The name of the hotspot.
    Use the position of the position as destination looking position.

  • fov (optionally)
    The destination fov (0 to 179).
    The looktohotspot action will use automatically the size of the hotspot as destination fov when the fov was not set. The other actions keep the current fov when not set.

  • motiontype (optionally)
    The type of the motion.

    Possible settings:
    • linear(speed) - a linear motion
      • speed = moving speed in degrees/second
    • smooth(accel,break,maxspeed) - accelerated smooth movement (=default)
      • accel = acceleration in degrees/second² (default=720)
      • break = negative acceleration in degrees/second² (default=-720)
      • maxspeed = maximum moving speed in degrees/second (default=720)

  • shortestway (optionally)
    The use the shortest possible way from the current to the destination position.

    Possible settings: true or false (default=true).
Examples
moveto(100.0,5,linear(10));
zoomto(130,smooth());
lookto(33,-22,30,smooth(100,50,20));
looktohotspot(hotspot1);
looktohotspot(hotspot2, 40);
looktohotspot(hotspot3, 25, smooth(100,50,20));
looktohotspot(get(name));
adjusthlookat(desthlookat)
Adjusts the view.hlookat value for manual tweening.
It fixes the 360 wrap around for the shortest way to desthlookat.

Parameters:
  • desthlookat
    The intended destination hlookat value. The current view.hlookat variable will be adjusted (without changing the current view) to be next to this value.
Examples
adjusthlookat(140);
tween(view.hlookat,140);
wait(parameter)
Wait a number of seconds or wait for an event.

Note - The user interface and all other actions are blocked during the waiting. That means the next action will be executed when the current action was done. The oninterrupt action can be used to make this action interrupt able by the user.

Parameters:
  • parameter
    • any number - this the time the action will wait in seconds
    • LOAD - wait until loading is finished
    • BLEND - wait until loading and blending are finished
Examples
oninterrupt(break);
lookto(150,30,70);
wait(3);
lookto(242,0,150);
lookto(280,-10,50);
wait(3);
loadpano(pano2.xml,null,MERGE,BLEND(2));
lookat(100,50,5);
wait(BLEND);
lookto(100,50,150);
freezeview(state)
When calling this action with true as parameter the current pano view will be freezed. Any further updates of any view setting will be change the current shown view. When freezed the rendering performance of the pano will be better because no redrawing will be necessary. Elements on top of the viewer (like plugin elements) will render faster.

Parameters:
  • state
    • true - freezes the current view
    • false - restores the normal state
oninterrupt(actions)
This action can be used before starting a set of actions (like lookto, looktohotspot, moveto, zoomto, wait and tween with WAIT as donecall) that are blocking the user interface.
When any of these actions will be interrupted by the user (e.g. by a click) then the these actions will be stopped and the in the oninterrupt action defined actions be executed.

Parameters:
  • actions
    • The action commands to call on a user interrupt.
    • Addtionally there is a special command possible here:
      break - this will just break the current actions.
Examples
oninterrupt(break);
lookto(150,30,70);
wait(3);
lookto(242,0,150);
lookto(280,-10,50);
wait(3);
oninterrupt( trace(user interrupt); );
lookto(0,0,90);			
lookto(90,0,90);
lookto(180,0,90);
lookto(270,0,90);
lookto(0,0,90);
screentosphere(x,y,h,v)
spheretoscreen(h,v,x,y)
Actions for converting between screen and spherical coordinates.
All paramters must be variables, using a value is not possible!

The screentosphere action will convert the x/y variables to the h/v variables and the spheretoscreen action the h/v variables to the x/y variables.

Parameters:
  • x / y
    Variables with screen coordniates in the pixels from the left top edge.
    spheretoscreen: When the variables don't exist they will be created.
  • h / v
    Variables with spherical coordniates in the degrees (360x180).
    screentosphere: When the variables don't exist they will be created.
Examples
screentosphere(mouse.x,mouse.y,toh,tov);
showtext(text,textstyle*)
Show a text message on the screen.

Note - only one text can be shown at one time! When calling showtext again the current shown text will be removed!

Parameters:
  • text
    • the text to show
    • html tags can be used in the text
    • but using html characters like '<' and '>' is not possible!
    • use '[' and ']' instead of it
    • for language specific characters use a set the Encoding of XML file or use a Unicode UTF8 or UTF16 XML file

    NOTE - to use some special characters like ',' or '<' and '>' they needed to be escape-coded in form %HH, where HH is the hex code of the character.
    e.g.: ',' = %2C
    for linebreaks just use [br] (=<br>) or '\n'


    examples tags for formating:
    • [b]bold[/b]
      - bold text
    • [i]italic[/i]
      - italic text
    • [u]underline[/u]
      - underlined text
    • [br]
      - linefeed

  • textstyle (optionally)
    the name of the textstyle to use for this text,
    if not defined the DEFAULT style is used
    see xml textstyle tag documentation
Examples
onhover="showtext(you are hovering me);"
onhover="showtext(style text,TEXTSTYLE);"
onhover="showtext(line 1[br]line 2[br]line 3);"
onhover="showtext([b]bold[/b] [i]italic[/i]);"


DEMO: view some textstyles interactive
updateobject(updateall*,updatefov*)
Updates / rebuilds the internal 3D model of the pano object.
This must be called after changes of the display.details and display.tessmode settings.
When changing of the image.hfov, image.vfov or image.voffset settings interactivly, this action must be called with updatefov=true to get an updated pano object!

Note - the rebuilding of the internal 3D model is a heavy process! This action should be used carefully!

Parameters:
  • updateall (optionally)
    For multi-resolution pano - should all levels be updated?
    Possible settings: true or false (default=false).
  • updatefov (optionally)
    Reparse the image.hfov, image.vfov and image.voffset settings when building the pano object.
    Possible settings: true or false (default=false).
Examples
set(image.hfov,1);
updateobject(true,true);
updatescreen()
  • Force a redraw of the panorama view.
  • The rendering quality will not change.
invalidatescreen()
addplugin(name)
addhotspot(name)
addlensflare(name,ath*,atv*)
Dynamically create and add a new plugin, hotspot element or lensflare element.

Parameters:
  • name
    Name of the new plugin, hotspot or lensflare element.
  • ath / atv (lensflare only)
    Horizontal and vertical position in degrees for the lensflare element.
Examples
addplugin(button);
set(plugin[button].url,button.jpg);
set(plugin[button].align,bottom);
set(plugin[button].x,10);
set(plugin[button].y,20);
set(plugin[button].onhover,showtext('hovering the new button'));
set(plugin[button].onclick, removeplugin(button) );
addhotspot(newspot);
set(hotspot[newspot].url,spot.png);
set(hotspot[newspot].ath,150);
set(hotspot[newspot].atv,30);
set(hotspot[newspot].scale,0.7);
set(hotspot[newspot].zoom,true);
set(hotspot[newspot].onclick, removehotspot(newspot) );
addhotspot(polyspot);
set(hotspot[polyspot].fillalpha, 0.25);
set(hotspot[polyspot].borderalpha, 0.50);
set(hotspot[polyspot].onclick, removehotspot(polyspot) );
set(hotspot[polyspot].point[0].ath,-10);
set(hotspot[polyspot].point[0].atv,-10);
set(hotspot[polyspot].point[1].ath,-10);
set(hotspot[polyspot].point[1].atv,+10);
set(hotspot[polyspot].point[2].ath,+10);
set(hotspot[polyspot].point[2].atv,+10);
set(hotspot[polyspot].point[3].ath,+10);
set(hotspot[polyspot].point[3].atv,-10);
addlensflare(sun, 20, -60);
set(lensflare[sun].set,  FLARESET2);
set(lensflare[sun].size, 0.7);
removeplugin(name)
removehotspot(name)
removelensflare(name)
Dynamically remove and destroy a plugin, hotspot element or lensflare element.

Parameters:
  • variable
    Name of the plugin, hotspot or lensflare element which should be removed.
js( jsfunction(parameters*) )
Call a global Javascript function.

Note - this action requires the External Interface of the Flashplayer! This means the action will work offline/locally only when the security settings of the Flashplayer were adjusted. See here for more detatils - Local / Offline Usage.

Parameters:
  • jsfunction
    The name of the Javascript function.
  • parameters (optionally)
    Parameters for the Javascript function. Using the get action to resolve variables is possible.
Examples
Code in the HTML or JS file:
function test(p1, p2, p3)
{
  alert(p1 +" hlookat=" + p2 + " vlookat=" + p3);
}
Code in the XML file:
onclick="js( test('Hello', get(view.hlookat), get(view.vlookat)) );"
fscommand(...)
The fscommand action can be used to control the standalone Flashplayer.

Use:
  • fscommand(quit)
    Quit the standalone flashplayer.
  • fscommand(showmenu,false)
    Hide the menubar of the standalone flashplayer (Windows only).
  • fscommand(exec,'application.exe')
    Start an external application.
    The 'application.exe' must be in a subfolder named "fscommand".
showlog(state*)
Show or hide the trace output log.

Parameters:
  • state (optionally)
    • true to show the log (default)
    • false to hide the log
trace(...)
Traces texts or the content of variables to the output log.

Note - many traces can affect the rendering performance!

Parameters:
  • ....
    Any text or variables. When passing a variable then automatically the content of the variable will be used.
Examples
trace('view.maxpixelzoom=', view.maxpixelzoom);
<events onkeydown="trace('keycode=',keycode);" />
onresize="trace('size=',stagewidth,'x',stageheight);"
onclick="trace('mouse clicked at ', mouse.x, ' / ', mouse.y);"
trace('xyz=',xyz,' get(xyz)=',get(xyz));
error(errormessage)
Show a fatal error message and stops panorama viewing.

Parameters:
  • errormessage
    The error message to show.