Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Mittwoch, 5. November 2008, 20:14

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

Mittwoch, 5. November 2008, 21:05

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:

Quellcode

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)

Quellcode

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:

Quellcode

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:

Quellcode

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


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

Quellcode

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

Mittwoch, 5. November 2008, 22:39

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

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

Quellcode

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


you can just use:

Quellcode

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:

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

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;


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

Quellcode

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


any questions for the moment?

4

Mittwoch, 5. November 2008, 22:50

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.

5

Freitag, 19. Dezember 2008, 17:42

Hi,

I've one question :

Why do we have a if condition her ?

Quellcode

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

Freitag, 19. Dezember 2008, 17:49

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

7

Freitag, 19. Dezember 2008, 18:01

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

Freitag, 19. Dezember 2008, 18:43

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


9

Sonntag, 18. Oktober 2009, 21:31

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

Sonntag, 18. Oktober 2009, 23:09

Quellcode

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

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

Quellcode

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



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

S.M.Taheri

11

Dienstag, 20. Oktober 2009, 08:21

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

Dienstag, 20. Oktober 2009, 18:46

here it is:

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;


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

Mittwoch, 21. Oktober 2009, 10:08

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

Mittwoch, 21. Oktober 2009, 19:44

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

Montag, 26. Oktober 2009, 22:01

Hi,

can you show an online example?

best regards,
Klaus

16

Donnerstag, 18. März 2010, 21:21

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

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:

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

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;


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

Quellcode

1

				


any questions for the moment?



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

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

S.M.Taheri

17

Donnerstag, 18. März 2010, 21:40

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

Ähnliche Themen