Sie sind nicht angemeldet.

1

Freitag, 19. Dezember 2008, 21:27

Toggle / Open and Close States

Is there a way to set an open and close state for a plugin / graphic ?

See this one for an example: http://wideeyes.dk/temp/krybily/ the menu items can be toggled and have a graphic that changes.

Please provide a sample code on how to achieve this.

2

Freitag, 19. Dezember 2008, 22:47

Hi,

there are more possibilities to do this:

1. change the onclick function:
  • there are 2 actions
  • one action for closeing
  • and one action for opening
  • in every action the onclick funtion is set to the other action
example xml - a button to show and hide a infoscreen:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<action name="showinfo">
    set(plugin[button].onclick,action(hideinfo));
    set(plugin[info].enabled,true);
    set(plugin[info].visible,true);
    tween(plugin[info].alpha,1.0,distance(1.0,0.2),easeOutQuart);
</action>
	
<action name="hideinfo">
    set(plugin[button].onclick,action(showinfo));
    set(plugin[info].enabled,false);
    tween(plugin[info].alpha,0.0,distance(1.0,0.2),easeOutQuart,set(plugin[info].visible,false));
</action>
	
<plugin name="button" ....
        onclick="action(showinfo);"
        />



2. use the new IF function: (1.0.8 beta 4 or higher)
  • use some of the existing variable (e.g. visible or enabled)
  • or create a own variable (e.g. state)
  • check this variable and decide what to do
xml example:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<plugin name="button" ... state="closed"
        onclick="if( state == closed , action( openaction ), action( closeaction) );"
        />

<action name="openaction">
    set(plugin[button].state, opened);
    set(plugin[info].visible,true);
</action>

<action name="closeaction">
    set(plugin[button].state, closed);
    set(plugin[info].visible,false);
</action>
 


best regards,
Klaus

3

Montag, 22. Dezember 2008, 11:35

This "if" function is very usefull, thank you ! :-)
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

4

Dienstag, 13. Januar 2009, 21:39

What a truly great piece of software! Unfortunately I'm having a difficult time implementing this IF statement... I can get it to work without the IF - i.e. onclick="action(openaction);" - any suggestions? Great work Klaus!

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
	<plugin name="panel"
			url="graphics/panel.png"
			zorder="1"
			origin="top"
			edge="centerbottom"
			x="0"
			y="45"
			alpha="0.99"
			scale="1.0" 
			state="closed"
			onclick="if (state == closed, action(openaction), action (closeaction));"
			/>

	<action name="openaction">
			tween(plugin[panel].y,650,0.75);
			set(plugin[panel].state, opened);
   	</action>

	<action name="closeaction">
			tween(plugin[panel].y,-650,0.75);
			set(plugin[panel].state, closed);
   	</action>

5

Mittwoch, 14. Januar 2009, 15:03

What a truly great piece of software! Unfortunately I'm having a difficult time implementing this IF statement... I can get it to work without the IF - i.e. onclick="action(openaction);" - any suggestions? Great work Klaus!

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
			url="graphics/panel.png"
			zorder="1"
			origin="top"
			edge="centerbottom"
			x="0"
			y="45"
			alpha="0.99"
			scale="1.0" 
			state="closed"
			onclick="if (state == closed, action(openaction), action (closeaction));"
			/>

	
			tween(plugin[panel].y,650,0.75);
			set(plugin[panel].state, opened);
   	

	
			tween(plugin[panel].y,-650,0.75);
			set(plugin[panel].state, closed);
   	

Try this
onclick="if(state == closed, action(openaction), action(closeaction));"

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Job.1« (14. Januar 2009, 15:16)


6

Mittwoch, 14. Januar 2009, 18:45

Thanks for the help, it works!
===============
Two things - for those who are trying to figure things out too...

I was negligent in replacing my krpano.swf with the 1.0.8beta5 - so it wouldn't work regardless!

I replaced my old krpano.swf (1.0.7) with the new one (1.0.8Beta5) - still didn't work with original code (mine).

I followed above suggestion and it worked - just had to remove 2 "space" characters in the appropriate spots.

8

Dienstag, 20. Januar 2009, 20:43

it didn't work with the spaces between?

sorry, I will check this, should be fixed soon

Ähnliche Themen