|
|
Quellcode |
1 |
import krpano_as3_interface; |
|
|
Quellcode |
1 2 3 4 5 6 |
if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
|
|
|
Quellcode |
1 2 3 4 5 6 |
var krpano : krpano_as3_interface = null;
function startplugin(event:Event):void
{
krpano = krpano_as3_interface.getInstance();
}
|
|
|
Quellcode |
1 2 |
var view:Object = krpano.get("view");
view.hlookat += 10.0;
|
|
|
Quellcode |
1 2 |
var hlookat:Number = krpano.get("view.hlookat");
krpano.set("view.hlookat", hlookat + 10 );
|
|
|
Quellcode |
1 |
<plugin name="pluginname" .... /> |
|
|
Quellcode |
1 |
var pluginobject:Object = krpano.get("plugin[pluginname]");
|
|
|
Quellcode |
1 |
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent); |
|
|
Quellcode |
1 2 3 4 5 |
function registerEvent(evt:DataEvent):void
{
var pluginpath:String = evt.data;
var pluginobject:Object = krpano.get(pluginpath);
}
|
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 |
function plugin_test_hello():void
{
// start debug and trace to the krpano log (open it by pressing 'O' in the viewer)
krpano.trace(krpano_as3_interface.STARTDEBUGMODE, "start debug mode");
krpano.trace(krpano_as3_interface.INFO, "hello from plugin");
}
// create a new function just by assigning it:
// (only one important note - all functions and attributes must be lowercase!)
pluginobject.myfunction = plugin_test_hello;
|
|
|
Quellcode |
1 |
<hotspot .... onclick="plugin[pluginname].myfunction();" /> |
|
|
Quellcode |
1 2 3 4 5 6 |
if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
|
in stopplugin function, all from the plugin added elements and events should be removed,what would be like the stopplugin function? *whistling*
you can show the code in it's context?i used this lines of code, but i get this error:
|
|
Quellcode |
1 2 3 4 5 6 7 |
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();//var view:Object = krpano.get("view");
if (krpano.get == null){// run plugin swf standalone - no interfaces - add dummy functions
function dummy_get(v:String):String{if (v != "progress.loaddone"){trace("get(" + v + ");");}return "";}function dummy_set(v:String,val:String):void{trace("set("+v+","+val+");");}
function dummy_call(action:String):void{trace("call("+action+");");}
krpano.get = dummy_get;krpano.set = dummy_set;krpano.call = dummy_call;}
krpano.set("plugin[GUI].autopos", "center,0,0");krpano.set("fullscreen", true);krpano.set("control.mousetype", "moveto");krpano.set("control.movetocursor", "arrow");//view.hlookat = 10;
|

yes krpano is running and plugin included to it using krpano.xml.Hi,
is krpano running and the plugin included to it? or do you start the plugin alone?
and the is krpano version 1.0.7 or higher?
in version 1.0.6 or lower the 'Object' method wouldn't work,
best regards,
Klaus

I continue with - how to access to the plugin itself:
if you know the "name" of the plugin,
this name:
![]()
Quellcode
1
you can just use:
![]()
Quellcode
1var pluginobject:Object = krpano.get("plugin[pluginname]");
to get a object to access all attributes of the plugin,
if the name is not fixed (the common case) add a a special "register plugin" event listener to get the path/name of the plugin:
![]()
Quellcode
1 krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
this event is dispatched from krpano after loading to the plugin, krpano passes a "DataEvent" Object with the name/path of the plugin:
![]()
Quellcode
1 2 3 4 5function registerEvent(evt:DataEvent):void { var pluginpath:String = evt.data; var pluginobject:Object = krpano.get(pluginpath); }
now you can read the attributes of the plugin,
or add attributes or function,
e.g. - to add a function that can be called from XML or from a other plugin - just do this:
![]()
Quellcode
1 2 3 4 5 6 7 8 9 10 11function plugin_test_hello():void { // start debug and trace to the krpano log (open it by pressing 'O' in the viewer) krpano.trace(krpano_as3_interface.STARTDEBUGMODE, "start debug mode"); krpano.trace(krpano_as3_interface.INFO, "hello from plugin"); } // create a new function just by assigning it: // (only one important note - all functions and attributes must be lowercase!) pluginobject.myfunction = plugin_test_hello;
to access this function from XML, e.g. on a hotspot click:
![]()
Quellcode
1
any questions for the moment?![]()
Zitat
1120: Access of undefined property pluginobject.
Zitat
pluginobject.myfunction = plugin_test_hello;
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();
if (krpano.get == null){
function dummy_get(v:String):String{if (v != "progress.loaddone"){trace("get(" + v + ");");}return "";}function dummy_set(v:String,val:String):void{trace("set("+v+","+val+");");}
function dummy_call(action:String):void{trace("call("+action+");");}
krpano.get = dummy_get;krpano.set = dummy_set;krpano.call = dummy_call;}
var stgW,stgH,scrW,scrH:uint;if (stage == null){addEventListener(Event.ADDED_TO_STAGE, startplugin);}
function startplugin(event:Event):void{stgW = stage.stageWidth;stgH = stage.stageHeight;scrW = stage.fullScreenWidth;scrH = stage.fullScreenHeight;}
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
function registerEvent(evt:DataEvent):void{var pluginpath:String = evt.data;var pluginobject:Object = krpano.get(pluginpath);}
function plugin_test_hello():void{krpano.trace(krpano_as3_interface.STARTDEBUGMODE, "start debug mode");krpano.trace(krpano_as3_interface.INFO, "hello from plugin");}
pluginobject.myfunction = plugin_test_hello;
|
