Hi,
Well i'm using a compass code in FPP, working fine and try (with no sucess so far) to adapt it to KRP
i have a plugin with a movieclip called "compass_ring_btn",
i want it rotate accordingly to the pano pan :
in FPP i use an invisible hotspot in xml
where "rotation" will be the north direction value
with this AS3 code in my plugin :
Code
//////////// COMPASS AS3 START CODE ///////////////////////////////////
//var movie:Sprite;///
//var hotspot:Object;///
//var pano:Object;///
var hotspots:Object;///
//
loaderInfo.addEventListener(Event.INIT, initHandler);
//
var sTimer:Timer; ///
function initHandler (event:Event) {
if (loaderInfo.loader!=null) {
// get link to hotspots plugin object:
hotspots = loaderInfo.loader.hotspots;
// setting refreshing timer
sTimer = new Timer(50);
sTimer.addEventListener("timer", updateFov);
sTimer.start();
}
}
function updateFov (e:Event) {
//
// get link to pano object:
pano = hotspots.getPano();
// get link to deltarotation hotspot
deltaRotation = hotspots.getSpot('deltarotation'); // deltarotation = hotspot ID
// calculating fov new rotation:
fovRotation = -pano.pan + deltaRotation.rotation;
//compass_ring_btn
compass_ring_btn.rotation = +fovRotation // rotate the compass accordingly to the pano pan
}
//////////// COMPASS AS3 END CODE ///////////////////////////////////
Display More
Then to adapt to KRP,
i make an invisible hotspot in xml like this :
Code
<hotspot name="deltarotation" url="any.png" handcursor="false" visible="false" ath="100" atv="0" >
where "ath" will be North direction...
and in my Plugin AS3 :
Code
// timer that reads hlookat and fov and updates the compass
updatetimer = new Timer(1000/30,0); // 30fps
updatetimer.addEventListener(TimerEvent.TIMER, updateFov);
updatetimer.start();
function updateFov (e:Event) {
//
// get link to pano object:
var view:Object = krpano.get("view");
// get link to deltarotation hotspot
var pluginobject:Object = krpano.get("plugin[deltarotation]");
// calculating fov new rotation:
deltaRotation.rotation = Number( krpano.get("plugin[deltarotation].ath") );
//compass_ring_btn
compass_ring_btn.rotation = deltaRotation.rotation // should rotate the compass accordingly to the pano pan
}
Display More
as you see, i'm pretty noob in AS3 :wacko: , because i'm designer.
so any help appreciated.
Thanks