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.

milotimbol

Intermediate

Posts: 220

Location: Philippines

Occupation: Software Developer

  • Send private message

21

Tuesday, July 13th 2010, 2:17am

it works! thanks! but I can't turn it back on. When the pano loads the mouse follow is on, when I click off it is disabled(or removed) but when I click on again it no longer adds the plugin. Any ideas?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	<plugin name="mouseFollowOnBtn" url="mouse-follow-on.png" alpha="0.9" visible="false" align="lefttop" edge="lefttop" y="-4" x="852" blendmode="normal" keep="true" onclick="action(mouseFollowOn);"/>
	<plugin name="mouseFollowOffBtn" url="mouse-follow-off.png" alpha="0.9" visible="true" align="lefttop" edge="lefttop" y="-4" x="852" blendmode="normal" keep="true" onclick="action(mouseFollowOff);"/>

	<action name="mouseFollowOn">
		addplugin(mousefollow);
		set(plugin[mousefollow].enabled, true);
		set(plugin[mouseFollowOffBtn].visible, true);
		set(plugin[mouseFollowOnBtn].visible, false);
	</action>	
	
	<action name="mouseFollowOff">
		set(plugin[mouseFollowOffBtn].visible, false);
		set(plugin[mouseFollowOnBtn].visible, true);
		removeplugin(mousefollow);
		set(hlookat_moveforce, 0);
		set(vlookat_moveforce, 0);

	</action>

Zephyr

Professional

Posts: 994

Location: Netherlands

Occupation: Web developer

  • Send private message

22

Tuesday, July 13th 2010, 8:06am

No sorry no clue :(

adding the plugin again should alsoo add the eventlisteners again. Maybe instead of removing the plugin you could alsoo bind an function with an action.

This updated code, doesnt start the plugin when its loaded, but when you call it by plugin[mousefollow].startit() en you stop it with stopit()
Not tested though.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package
{
    import flash.display.Sprite;
    import flash.events.Event;

    import krpano_as3_interface;


    public class followmouse extends Sprite
    {
        private var krpano : krpano_as3_interface = null;

        private var control_mousetype_backup:String = null;
		private var pluginpath : String = null;
		private var pluginobj  : Object = null;
		
        public function followmouse()
        {
            if (stage == null)
            {
                this.addEventListener(Event.ADDED_TO_STAGE, startplugin);
                this.addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
            }
        }

        private function startplugin(evt:Event):void
        {
            krpano = krpano_as3_interface.getInstance();
			
			//register actions to flash functions
			pluginpath = evt.data;							
        	pluginobj  = krpano.get(pluginpath);
			krpano.set(pluginpath+".stopit", startListening);
			krpano.set(pluginpath+".startit", stopListening);
			
            if ( krpano.get("version") < "1.0.7" )
            {
                krpano.call("error(followmouse plugin - wrong krpano version! 1.0.7 or higher needed);");
                return;
            }

            // save current control mode
            control_mousetype_backup = krpano.get("control.mousetype");
            
            // disable default mouse control
            krpano.set("control.mousetype", "off");

            // add frame listener -- DISABLED SO YOU CAN MANUALLY CALL IT
            //addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
        private function stopListening():void
		{
			 stopplugin(null);
		}
		private function startListening():void
		{
			 addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}
        private function stopplugin(evt:Event):void
        {
            // remove frame listener
            removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
                    
            // restore old controlmode
            krpano.set("control.mousetype", control_mousetype_backup);
        }

        private function enterFrameHandler(event:Event):void
        {
            var mx:Number = stage.mouseX;
            var my:Number = stage.mouseY;
            var sx:Number = stage.stageWidth  * 0.5;
            var sy:Number = stage.stageHeight * 0.5;

            // calc motion vectors: -1.0 to +1.0
            var vx:Number = (mx - sx) / sx;
            var vy:Number = (my - sy) / sy;

            // advance it a little bit:
            // - make moving slower in the middle
            // - and faster in the outer regions
            vx = (vx < 0 ? -1.0 : +1.0) * Math.pow(Math.abs(vx), 2.0);
            vy = (vy < 0 ? -1.0 : +1.0) * Math.pow(Math.abs(vy), 2.0);
            
            // stop very slow moving
            if (Math.abs(vx) < 0.01)    vx = 0;
            if (Math.abs(vy) < 0.01)    vy = 0;

            // set move forces
            krpano.set("hlookat_moveforce", vx);
            krpano.set("vlookat_moveforce", vy);
        }
    }
}
3d childrens game using krpano Game
Minify your xml with my krpano XML Compressor
Krpano XML Parsing Error Checklist
Available for hire (krpano xml, javascript, actionscript, flash, php and ipad plugins).

23

Tuesday, October 26th 2010, 12:57pm

Where do I paste this code for working "area"? Trying to paste into the html file:

Source code

1
var swf = createswf("krpano.swf", "krpanoSWFObject", "100%", "100%");var area:Object = krpano.get("area");  var mx:Number = stage.mouseX * 0.5;  var my:Number = stage.mouseY * 0.5;  var sx:Number = area.pixelwidth  * 0.5;  var sy:Number = area.pixelheight * 0.5;  swf.addVariable("xml", "test_area.xml");  swf.addParam("wmode","transparent");  swf.embed("krpanoDIV");




But, unfortunately, does not work at all *confused*

edit: How I can edit this plugin code?
I have:
- followmouse.as
- followmouse.swf

Im totally newbie in flash and i would like to set the area in this plugin. Someone help me? *mellow*

This post has been edited 1 times, last edit by "d&g" (Oct 26th 2010, 4:23pm)


jeromebg

Professional

Posts: 729

Location: Angers - France

Occupation: Photographer

  • Send private message

24

Thursday, September 22nd 2011, 11:51am

Hi, is there a way to use this plugin but only horizontal ?
I don't want to follow the mouse up and down, is it possible ?

Thanx !!!

25

Monday, September 26th 2011, 5:32pm

Hi,
Hi, is there a way to use this plugin but only horizontal ?
I don't want to follow the mouse up and down, is it possible ?
yes, but only by editing the code,
e.g. remove this line:

Source code

1
krpano.set("vlookat_moveforce", vy);
and the vertical movement will be not set,

to compile the .as file to a .swf file you need to download the Flex SDK and adjust the path in the mxmlc_compile.bat to it,

best regards,
Klaus

26

Thursday, June 28th 2012, 6:40pm

Solution

Hello, i have a solution to turn on and off this plugin. Here my solution.
She work well on this web site http://www.rauzier-hyperphoto.com/menus-plaisirs/
I give a wrong url adress to setup the mousefollow off.


<plugin name="mousefollow" url="followmouse.swf" visible="false" keep="true" enabled="false" />
<action name="mousefollow-off">
set(vlookat_moveforce,0);
set(hlookat_moveforce,0);
set(plugin[mousefollow].url,followmouseoff.swf);
</action>

<action name="mousefollow-on">
set(plugin[mousefollow].url,followmouse.swf)
</action>

<plugin name="papa-barre" keep="true" align="bottom" x="0" y="0" url="vide.png" width="100%" height="60" onover="mousefollow-off();" onhover="tween(alpha,1); " onout="tween(alpha,0); action(qtvrcursor); mousefollow-on(); " alpha="1" onloaded="" zorder="2"/>

danimorgo

Beginner

Posts: 42

Location: argentina

Occupation: diseƱador

  • Send private message

27

Friday, March 21st 2014, 8:38pm

question

is possible to control the acceleration and friction of the mouse?

28

Friday, March 28th 2014, 8:57am

is possible to control the acceleration and friction of the mouse?
Hi,

yes, the *_moveforce settings are basically used by keyboard control - therefore the keyboard related control settings will affect the movement in this case.

Look here for the keybaccelerate, keybspeed and keybfriction settings:
http://krpano.com/docu/xml/#control.advanced

Best regards,
Klaus

29

Thursday, March 3rd 2016, 8:41pm

HTML5 Version

I rewrote this for HTML5 if anyone wants it:

https://github.com/BOXNYC/krpano-plugins…/followmouse.js

Cheers!

This post has been edited 2 times, last edit by "BOX" (Mar 4th 2016, 1:39am)


herrpedro

Trainee

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

30

Thursday, September 27th 2018, 10:32pm

I rewrote this for HTML5 if anyone wants it:

https://github.com/BOXNYC/krpano-plugins…/followmouse.js

Cheers!



thank you!

Similar threads