Hi, i need pass event betwen two plugin and krpano, like this graphic
plugin1---->krpano--->plugin2
plugin2--->krpano--->plugin1
krpano--->plugin1---->plugin2
lot of thank very good soft.
Hi, i need pass event betwen two plugin and krpano, like this graphic
plugin1---->krpano--->plugin2
plugin2--->krpano--->plugin1
krpano--->plugin1---->plugin2
lot of thank very good soft.
Hi, okay I will try to explain how to develop plugins:
first copy the krpano_as3_interface.as to your flash project folder,
and import it:
then you should add a Listeners for waiting until the plugin was added to the stage:
(also add the a remove event to clean everything of the plugin)
if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
then it's time to get a interface to krpano,
create a variable of the krpano_as_interface class and
call the static getInstance() function to get a interface object:
var krpano : krpano_as3_interface = null;
function startplugin(event:Event):void
{
krpano = krpano_as3_interface.getInstance();
}
with this krpano_as3_interface object you can access all krpano objects or data from the xml file with it,
e.g. if you want to change this view settings - get the whole view object:
or you can also get/set each attribute with set and get:
but the first method is recommended, using krpano.get / krpano.set is slow!
everything clear for the moment?
I continue with - how to access to the plugin itself:
if you know the "name" of the plugin,
this name:
you can just use:
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:
this event is dispatched from krpano after loading to the plugin, krpano passes a "DataEvent" Object with the name/path of the plugin:
function 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:
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;
Display More
to access this function from XML, e.g. on a hotspot click:
any questions for the moment?
hi, klaus, first a lot of thanks for the explanation, i've solved for a while the problem begin of how to detect the event of ipdate plugin by attribute, the prioblem begin of how to detect the atrribute i've use the tutorial example, but only works width tahis.
krpano.get("plugin[pluginname]");
thanks sure great work.
Hi,
I've one question :
Why do we have a if condition her ?
if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
What does it mean, to be on the stage or not, for the plug-in ?
If we call it, it can be somewhere else than the stage ?
Thanks for the answer,
Hi,
when stage == null the plugin was started from krpano, and the plugin can use getInstance() to
get access to krpano,
but when stage is set - the plugin was started standalone, and access to krpano will fail,
in my plugins I used this to show the version number of the plugin, when starting it standalone,
best regards,
Klaus
Okay, thanks for yor quick answer
but how can we start the plugin without being in krpano (= in standalone mode) ?
I read actually we can't embed krpano in a flash container.
I miss something I thing
I'm mean by a opening the plugin swf direct,
e.g.
https://krpano.com/plugins/editor.swf
if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
what would be like the stopplugin function?
Hi,
what would be like the stopplugin function?
in stopplugin function, all from the plugin added elements and events should be removed,
i used this lines of code, but i get this error:
you can show the code in it's context?
has the "krpano" object a value? (not 'null')
was "krpano_as3_interface.getInstance()" called before?
is the plugin running inside krpano?
best regards,
Klaus
here it is:
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;
this block of code works fine, but i want to use Object method you mentioned above.
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
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
yes krpano is running and plugin included to it using krpano.xml.
my krpano versin is 1.0.8 beta8.
Hi,
can you show an online example?
best regards,
Klaus
Display MoreI continue with - how to access to the plugin itself:
if you know the "name" of the plugin,
this name:you can just use:
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:
this event is dispatched from krpano after loading to the plugin, krpano passes a "DataEvent" Object with the name/path of the plugin:
Codefunction 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:
Code Display Morefunction 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:
any questions for the moment?
I use this block of code but i got this error:
Quote1120: Access of undefined property pluginobject.
Quotepluginobject.myfunction = plugin_test_hello;
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;
Display More
dear klaus,
could you please put a practical example for this thread here?
best regards
Don’t have an account yet? Register yourself now and be a part of our community!