<!--
	krpano 1.0.8
	- flyout more hotspots example
	- when one hotspot is flying out, all others will fly back in
-->

<krpano version="1.0.8" onstart="showtext('[b][i]krpano[br]flyout more hotspots example[/i][/b]', infostyle);">

	<!-- text style for startup text -->
	<textstyle name="infostyle"
	           origin="center" edge="center" yoffset="-100" textalign="center" background="false" border="false"
	           fontsize="40" textcolor="0xFFFFFF" bold="false" effect="glow(0xFFFFFF,0.7,4,2);glow(0x000000,1,4,2);dropshadow(3,45,0x000000,2,0.6);"
	           showtime="4.0" fadeintime="1.0" fadetime="1.0"
	           />

	<!-- use only a grid preview pano (to save download space) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />

	<!-- view settings -->
	<view hlookat="12" vlookat="40" fov="105" />


	<!-- use a <style> to share the same attriubtes for all hotspots -->
	<style name="flyoutimage"
	       distorted="true"
	       backup_rx="0"
	       backup_ry="0"
	       backup_rz="0"
	       backup_scale="0"
	       backup_zorder="0"
	       flying="0.0"
	       flystate="0"
	       onclick="if(flystate == 0, flyout_by_name(get(name)), flyback_by_name(get(name)) );"
	       />

	<hotspot name="spot1" style="flyoutimage"
	         url="image1.jpg"
	         zorder="1"
	         ath="45"
	         atv="54"
	         scale="0.5"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />

	<hotspot name="spot2" style="flyoutimage"
	         url="image2.jpg"
	         zorder="2"
	         ath="60"
	         atv="54"
	         scale="0.5"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />

	<hotspot name="spot3" style="flyoutimage"
	         url="image3.jpg"
	         zorder="3"
	         ath="75"
	         atv="58"
	         scale="0.5"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />


	<!--
		flyout/flyback actions
		(for more stylish in/out animations play with different tweentypes and times)
	-->

	<action name="flyout_by_name">
		<!-- make all other hotspots flying back -->
		flyback_others();

		<!--
			for best control set 4 fly states:
			0 = normal
			1 = while flying out
			2 = out
			3 = while flying back
		-->

		<!-- save original position/rotation -->
		if(hotspot[%1].flystate == 0,
		    copy(hotspot[%1].backup_rx,     hotspot[%1].rx);
		    copy(hotspot[%1].backup_ry,     hotspot[%1].ry);
		    copy(hotspot[%1].backup_rz,     hotspot[%1].rz);
		    copy(hotspot[%1].backup_scale,  hotspot[%1].scale);
		    copy(hotspot[%1].backup_zorder, hotspot[%1].zorder);
		  );

		<!-- set new state -->
		set(hotspot[%1].flystate,1);
		set(hotspot[%1].zorder,99);

		<!-- tween the rotations values to 0 for a flat screen view -->
		tween(hotspot[%1].rx, 0);
		tween(hotspot[%1].ry, 0);
		tween(hotspot[%1].rz, 0);
		tween(hotspot[%1].scale, 1.5);

		<!--
			tween 'flying' to 1.0,
			this makes the hotspot independent from the panorama rotation and scaling
		-->
		tween(hotspot[%1].flying, 1.0, 0.5, default, set(hotspot[%1].flystate,2); );
	</action>


	<action name="flyback_by_name">
		if(hotspot[%1].flystate != 3,
			set(hotspot[%1].flystate,3);

			<!-- tween back to the stored backup values -->
			tween(hotspot[%1].rx,    get(hotspot[%1].backup_rx)    );
			tween(hotspot[%1].ry,    get(hotspot[%1].backup_ry)    );
			tween(hotspot[%1].rz,    get(hotspot[%1].backup_rz)    );
			tween(hotspot[%1].scale, get(hotspot[%1].backup_scale) );

			copy(hotspot[%1].zorder, hotspot[%1].backup_zorder);

			<!-- tween 'flying' also back to 0.0 -->
			tween(hotspot[%1].flying, 0.0, 0.5, default, set(hotspot[%1].flystate,0); );
		  );
	</action>


	<action name="flyback_others">
		if(%1 != nextloop, set(i,0));
		
		if(hotspot[%i].style == flyoutimage,
			if(hotspot[%i].flystate != 0, flyback_by_name(get(hotspot[%i].name)); );
		  );
		  
		inc(i);
		if(i LT hotspot.count, flyback_others(nextloop); );
	</action>


</krpano>

