You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, November 5th 2008, 8:14pm

hi, im making plugin problem with event

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.

2

Wednesday, November 5th 2008, 9:05pm

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:

Source code

1
import krpano_as3_interface;


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)

Source code

1
2
3
4
5
6
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:

Source code

1
2
3
4
5
6
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:

Source code

1
2
var view:Object = krpano.get("view");
view.hlookat += 10.0;


or you can also get/set each attribute with set and get:

Source code

1
2
var hlookat:Number = krpano.get("view.hlookat");
krpano.set("view.hlookat", hlookat + 10 );


but the first method is recommended, using krpano.get / krpano.set is slow!

everything clear for the moment?

3

Wednesday, November 5th 2008, 10:39pm

I continue with - how to access to the plugin itself:

if you know the "name" of the plugin,
this name:

Source code

1
<plugin name="pluginname" .... />


you can just use:

Source code

1
var 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:

Source code

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:

Source code

1
2
3
4
5
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:

Source code

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;


to access this function from XML, e.g. on a hotspot click:

Source code

1
<hotspot .... onclick="plugin[pluginname].myfunction();" />


any questions for the moment?

4

Wednesday, November 5th 2008, 10:50pm

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.

nelk

Intermediate

Posts: 358

Location: Paris

  • Send private message

5

Friday, December 19th 2008, 5:42pm

Hi,

I've one question :

Why do we have a if condition her ?

Source code

1
2
3
4
5
6
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,
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

6

Friday, December 19th 2008, 5:49pm

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

nelk

Intermediate

Posts: 358

Location: Paris

  • Send private message

7

Friday, December 19th 2008, 6:01pm

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
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

8

Friday, December 19th 2008, 6:43pm

I'm mean by a opening the plugin swf direct,
e.g.
http://krpano.com/plugins/editor.swf


9

Sunday, October 18th 2009, 9:31pm

if (stage == null)
{
// plugin startup
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}

what would be like the stopplugin function? *whistling*
I wish my Blood was Blue

S.M.Taheri

10

Sunday, October 18th 2009, 11:09pm

Source code

1
var view:Object = krpano.get("view");

i used this lines of code, but i get this error:

Source code

1
TypeError: Error #1006: value is not a function.



what's the problem?
I wish my Blood was Blue

S.M.Taheri

11

Tuesday, October 20th 2009, 8:21am

Hi,
what would be like the stopplugin function? *whistling*
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

12

Tuesday, October 20th 2009, 6:46pm

here it is:

Source code

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;


this block of code works fine, but i want to use Object method you mentioned above.
I wish my Blood was Blue

S.M.Taheri

13

Wednesday, October 21st 2009, 10:08am

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

14

Wednesday, October 21st 2009, 7:44pm

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.
I wish my Blood was Blue

S.M.Taheri

15

Monday, October 26th 2009, 10:01pm

Hi,

can you show an online example?

best regards,
Klaus

16

Thursday, March 18th 2010, 9:21pm

I continue with - how to access to the plugin itself:

if you know the "name" of the plugin,
this name:

Source code

1

				


you can just use:

Source code

1
var 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:

Source code

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:

Source code

1
2
3
4
5
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:

Source code

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;


to access this function from XML, e.g. on a hotspot click:

Source code

1

				


any questions for the moment?



I use this block of code but i got this error:

Quoted

1120: Access of undefined property pluginobject.

Quoted

pluginobject.myfunction = plugin_test_hello;

Source code

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;
I wish my Blood was Blue

S.M.Taheri

17

Thursday, March 18th 2010, 9:40pm

dear klaus,
could you please put a practical example for this thread here? *cry*
best regards
I wish my Blood was Blue

S.M.Taheri

Similar threads