Is it possible to trace the time of the laptop that is running your tour? So on the one of the user..
if yes, then it will be possible to make a clock that always gives the 'correct time' isn't it?
Can we do that?
Cheers
Tuur
Is it possible to trace the time of the laptop that is running your tour? So on the one of the user..
if yes, then it will be possible to make a clock that always gives the 'correct time' isn't it?
Can we do that?
Cheers
Tuur
In my Virtual city tour Feldkirch360 I´v implemented a real-time-clock at the church as you can see here (watch the clock):
Virtual Panorama Tour Feldkirch360
It´s done via Flash (search at google for time-codes) and implement the swf in krpano as hotspot.
Marc
FPP has a real time clock plugin already. If they can do it we can do it, somehow.
Easy, just give me a few secs
Ok here's a setup with a digital 12hour clock. Analog clock is possible, but I need to draw the handles and such.
Use plugin[pluginname].gettime to trace the time and getdate to trace the date (untested, but should work fine).
you can alsoo enable/disable the digital clock and date by adding showtime="true/false" showdate="true/false" in the plugin attributes(alsoo untested).
import flash.utils.Timer;
import flash.events.TimerEvent;
import krpano_as3_interface;
var krpano : krpano_as3_interface = null;
var pluginpath : String = null;
var pluginobj : Object = null;
var ShowAnalog:Boolean = false;
var ShowDigital:Boolean = true;
var ShowDate:Boolean = true;
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, showClock);
if (stage)
{
stage.scaleMode = StageScaleMode.NO_SCALE;// no automatic scaling
stage.align = StageAlign.TOP_LEFT;// align on top left corner
timer.start();
}
else
{
this.addEventListener(Event.ADDED_TO_STAGE, startClock);
this.addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
function startClock(event:Event)
{
krpano = krpano_as3_interface.getInstance();
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
timer.start();
}
function registerEvent(evt:DataEvent):void
{
// register event - "data" is the name of the plugin
pluginpath = evt.data;
pluginobj = krpano.get(pluginpath);
var param:* = null
//<plugin name="clock" showanalog="true/false" showdigital="true/false" showdate="true/false"
//maybe more options later like font color/size/family
param = krpano.get(pluginpath + ".showanalog");
if (param != undefined && param != "")
ShowAnalog = String( param ).toLowerCase() != "false";
param = krpano.get(pluginpath + ".showdate");
if (param != undefined && param != "")
ShowDate = String( param ).toLowerCase() != "false";
param = krpano.get(pluginpath + ".showdigital");
if (param != undefined && param != "")
ShowDigital = String( param ).toLowerCase() != "false";
//register functions so you can trace the date/time
krpano.set(pluginpath+".gettime", krgetTime);
krpano.set(pluginpath+".getdate", getTime);
}
function showClock(event:TimerEvent)
{
/*
if(ShowAnalog)
{
var time:Date = new Date();
var seconds = time.getSeconds();
var minutes = time.getMinutes();
var hours = time.getHours();
//Rotates the pointers on the clock
//hourMC.rotation = 30 * hours + minutes / 2;
//minuteMC.rotation = 6 * minutes;
//secondMC.rotation = 6 * seconds;
}*/
if(ShowDigital)
{
timeTF.text = getTime();
}
if(ShowDate)
{
dateTF.text = getDate();
}
}
function krgetTime()
{
krpano.trace(0, "the current time is: " + getTime());
}
function krgetDate()
{
krpano.trace(0, "the current date is: " + getDate());
}
function getTime():String
{
var time:Date = new Date();
var seconds = time.getSeconds();
var minutes = time.getMinutes();
var hours = time.getHours();
if (minutes<10) {
minutes = "0"+minutes;
}
if (seconds<10) {
seconds = "0"+seconds;
}
var currenttime:String = ConvertHour(hours) + ":" + minutes + ":" + seconds;
return currenttime
}
function getDate():String
{
var time:Date = new Date();
var day:Number = time.getDay();
var month:Number = time.getMonth();
var date:Number = time.getDate();
var year:Number = time.getFullYear();
var currentdate:String = findDay(day) + " " + findMonth(month) + " " + date + " " + year;
return currentdate
}
function findDay(day:Number):String
{
if (day==0){
return "Sunday"
} else if (day==1){
return "Monday"
} else if (day==2){
return "Tuesday"
} else if (day==3){
return "Wednesday"
} else if (day==4){
return "Thursday"
} else if (day==5){
return "Friday"
} else if (day==6){
return "Saturday"
}
return ""
}
function findMonth(month:Number):String
{
if (month==0){
return "January"
} else if (month==1){
return "February"
} else if (month==2){
return "March"
} else if (month==3){
return "April"
} else if (month==4){
return "May"
} else if (month==5){
return "June"
} else if (month==6){
return "July"
} else if (month==7){
return "August"
} else if (month==8){
return "September"
} else if (month==9){
return "October"
} else if (month==10){
return "November"
} else if (month==11){
return "December"
}
return ""
}
function ConvertHour(hours:Number):String
{
//converts 24hours to 12hours notation
var convertedhours:String;
if (hours>12 )
{
convertedhours = String(hours-12);
}
if (hours == 0)
{
convertedhours = "12";
}
return convertedhours
}
function stopplugin(evt:Event)
{
krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
krpano = null;
timer.removeEventListener(TimerEvent.TIMER, showClock);
}
Alles anzeigen
He Zephyr,
Great!!
gonna check that out..
..
...
Now to try to get it working in the tour...
Master nr. 3 ...
Also for you free drinks in the bar this weekend..
I hope there are not to much masters here because the bar will be full of 'free' drinkers...
somebody wanna try to make the analoque one??
Tuur
Very nice and easy to use. I love that you didn't just show the as3 code but also zipped a package with a swf too for us Flash ignorant users.
....
Oke
i have the plugin like:
<plugin name="clock" url="../plugins/clock.swf" autopos="lefttop,10,10" visible="true" keep="true" alpha="1" scale="1" Parent="STAGE" zorder="101" />
blablablaedit..
EDIT : we don't need that... sorry mis understood..
It works perfect but not with parent ="STAGE"
Is it possible to make that? Zephyr?
...
another edit...
mmm
now it gives: null and minutes and seconds and date ...(no hours )..??
didn't changed a thing..
maybe because it is 01 on the mac.. i put it on 12 hours...
lets have aplay with the .fla file..
...
Thanx
Tuur
Still NULL on the hours...
Tuur
Ahh
the parent stage..
change in the .fla this:
this.addEventListener(Event.ADDED_TO_STAGE, startClock);
to:
timer.start();
voila!
Thanx Zephyr for teh PM on this.
Tuur
updated it, added a analog clock (showanalog="true" to view it)
added converthours propery (converthours="true") set it on true to do a 12h notation, false if you want 24h notation.
apperently if parent="STAGE" the ADDED_TO_STAGE eventlistener isnt triggered (a bug perhaps klaus?) to temporarily fix it, I started the timer immedietly (although you get a flash error if you the debugger installed, saying the child cant be addressed since it does not exist on stage yet).
import flash.utils.Timer;
import flash.events.TimerEvent;
import krpano_as3_interface;
var krpano : krpano_as3_interface = null;
var pluginpath : String = null;
var pluginobj : Object = null;
var ShowAnalog:Boolean = true;
var ShowDigital:Boolean = true;
var ShowDate:Boolean = true;
var ConvertHours:Boolean = false;
var clockMC:Clock = new Clock();
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, showClock);
if (stage)
{
stage.scaleMode = StageScaleMode.NO_SCALE;// no automatic scaling
stage.align = StageAlign.TOP_LEFT;// align on top left corner
timer.start();
}
else
{
//this.addEventListener(Event.ADDED_TO_STAGE, startClock);
timer.start();
this.addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
function startClock(event:Event)
{
krpano = krpano_as3_interface.getInstance();
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
timer.start();
}
function registerEvent(evt:DataEvent):void
{
// register event - "data" is the name of the plugin
pluginpath = evt.data;
pluginobj = krpano.get(pluginpath);
var param:* = null
//<plugin name="clock" showanalog="true/false" showdigital="true/false" showdate="true/false"
//maybe more options later like font color/size/family
param = krpano.get(pluginpath + ".showanalog");
if (param != undefined && param != "")
ShowAnalog = String( param ).toLowerCase() != "false";
param = krpano.get(pluginpath + ".showdate");
if (param != undefined && param != "")
ShowDate = String( param ).toLowerCase() != "false";
param = krpano.get(pluginpath + ".showdigital");
if (param != undefined && param != "")
ShowDigital = String( param ).toLowerCase() != "false";
param = krpano.get(pluginpath + ".converthours");
if (param != undefined && param != "")
ConvertHours = String( param ).toLowerCase() != "false";
//register functions so you can trace the date/time
krpano.set(pluginpath+".gettime", krgetTime);
krpano.set(pluginpath+".getdate", getTime);
}
function showClock(event:TimerEvent)
{
if(ShowAnalog)
{
var time:Date = new Date();
var seconds = time.getSeconds();
var minutes = time.getMinutes();
var hours = time.getHours();
//Rotates the pointers on the clock
if(!clockMC.parent)
{
this.addChild(clockMC);
clockMC.y = timeTF.height + dateTF.height+ 10;
}
clockMC.hourMC.rotation = 30 * hours + minutes / 2;
clockMC.minuteMC.rotation = 6 * minutes;
clockMC.secondMC.rotation = 6 * seconds;
}
if(ShowDigital)
{
timeTF.text = getTime();
}
if(ShowDate)
{
dateTF.text = getDate();
}
}
function krgetTime()
{
krpano.trace(0, "the current time is: " + getTime());
}
function krgetDate()
{
krpano.trace(0, "the current date is: " + getDate());
}
function getTime():String
{
var time:Date = new Date();
var seconds = time.getSeconds();
var minutes = time.getMinutes();
var hours = time.getHours();
if (minutes<10) {
minutes = "0"+minutes;
}
if (seconds<10) {
seconds = "0"+seconds;
}
var currenttime:String = ConvertHour(hours) + ":" + minutes + ":" + seconds;
return currenttime
}
function getDate():String
{
var time:Date = new Date();
var day:Number = time.getDay();
var month:Number = time.getMonth();
var date:Number = time.getDate();
var year:Number = time.getFullYear();
var currentdate:String = findDay(day) + " " + findMonth(month) + " " + date + " " + year;
return currentdate
}
function findDay(day:Number):String
{
if (day==0){
return "Sunday"
} else if (day==1){
return "Monday"
} else if (day==2){
return "Tuesday"
} else if (day==3){
return "Wednesday"
} else if (day==4){
return "Thursday"
} else if (day==5){
return "Friday"
} else if (day==6){
return "Saturday"
}
return ""
}
function findMonth(month:Number):String
{
if (month==0){
return "January"
} else if (month==1){
return "February"
} else if (month==2){
return "March"
} else if (month==3){
return "April"
} else if (month==4){
return "May"
} else if (month==5){
return "June"
} else if (month==6){
return "July"
} else if (month==7){
return "August"
} else if (month==8){
return "September"
} else if (month==9){
return "October"
} else if (month==10){
return "November"
} else if (month==11){
return "December"
}
return ""
}
function ConvertHour(hours:Number):Number
{
//converts 24hours to 12hours notation
var convertedhours:Number;
if(ConvertHours)
{
if (hours > 12)
{
convertedhours = hours-12;
}
if (hours == 0)
{
convertedhours = 12;
}
}
else
{
convertedhours = hours;
}
return convertedhours
}
function stopplugin(evt:Event)
{
krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
krpano = null;
timer.removeEventListener(TimerEvent.TIMER, showClock);
}
Alles anzeigen
PS the analog clock is ugly, this is to stimulate people to make there own clock + i dont have the time to make it nice ;p You can edit the clock file in the library. just dont alter the instance names of the clockhandlers.
Hello,
I downloaded the clock zip file and modified to suit my needs as I only need to display the current date. Thank you for the code on this. Locally it works great as is and will display the date for me but when I upload it to my service provider it doesn't work. I tried with the getdate statement and again locally it works but nothing on the server. Any suggestions?
Below is the coding.
Thanks in advance.
Robert
ZitatAlles anzeigen<plugin name="infobar_date" keep="true" style="infobar_style" zorder="1100" visible="true"
alpha="1" align="leftbottom" x="215" y="-20" onloaded="delayedcall(2,show_start_infobar(); action(showdate,date));"
/>
<plugin name="infobar_views" keep="false" style="infobar_style" zorder="1100" visible="true"
html="[p align='right'][font size='14']1,234[/font] views[/p]" alpha="1" align="rightbottom" x="165" y="-20" onloaded="delayedcall(2,show_start_infobar());"
/><plugin name="date" url="plugins/clock.swf"
align="leftbottom" x="210" y="0" visible="false"
keep="true"
zorder="1101"
showdate="true"
showtime="false"
selectable="false"
alpha="1"
shadow="5"
autosize="center"
/><action name="show_start_infobar">
tween(plugin[infobar_date].y,2,0.5);
tween(plugin[infobar_views].y,4,0.5);
</action><action name="showdate">
set(plugin[date].getdate,true);
set(plugin[date].visible,true);
tween(plugin[date].alpha,1);
</action>
Sorry, I've had some stuff disabled apperently in the FLA for testing purposes. Alsoo the getdate/time was badly linked.
plugin property:
showdate="false" or "true" shows the date
showdigital="false" or "true" shows a digital clock
showanalog="false" or "true" Shows the analog clock with the handles
converthours = "false" or "true" Converts 24hour notation to a 12hour notation
plugin functions:
gettime() - for debugging, traces the time in the trace log
getdate() - for debugging, traces the date in the trace log.
Usage example (shows date only):
GREAT!!
Tuur
thanks a bunch. I'll work on this later today.
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!