Create a Digital Clock with 4 actions in QuID

You have completed your first interactive designs with QuarkXPress 7, 8 & 9 and now have need for more advanced functionality. Discuss Expressions here, ask questions and learn more about them.
Please note that Flash (SWF) authoring is not supported in QuarkXPress 10 anymore.
Kabir(Quark)
Posts: 5
Joined: 30 Oct 2006, 23:29

Create a Digital Clock with 4 actions in QuID

Post by Kabir(Quark) » 13 Aug 2007, 01:09

Hi

In this exercise we will create a digital clock using just 4 actions. This exercise will also help explore some lesser used actions in QuiD.

Steps
-----

1) Create a text box and make it a textbox object , call it "clock"
2)Create a new script and add the following actions to it

(i) Apply the Expression set action and type the expression below-
Clock.Append(Date.GetHours() + ":" + Date.GetMinutes() + ":" + Date.GetSeconds())

The Append() function is used to put some text in a text box object e.g. Clock.Append("The time is") would put the text within quotes in the text box named clock

The function Date.GetHours() returns the hour as apecified by the system time. e.g. if the time is 11:33 , this function will return 11

The function Date.GetMinutes() returns the minute as apecified by the system time. e.g. if the time is 11:33 , this function will return 33

The function Date.GetSeconds() returns the second as apecified by the system time.

The + operator serves as a concatenation operator that just joins the various strings togther , here it is used to join the values returned by these functions with a semi colon ":"

(ii) Apply Action Other->Delay and give a delay of 1 second

This is done to update the clock every 1 second as we will add a run script action to make this script run in an endless loop

(iii) Apply action Object-> Reset to the text box object "clock

This is done to clear the content of the text box every 1 second so that the new current time can be displayed in it

(iv) Apply Action Script run -> Script 1 (Where Script1 is the current script that you are creating)

This is done so that this script plays in an endless loop every 1 second

3)Now , all you have to do is use this script as the page entry script and you have a working digital clock using just 4 simple actions.


Hope you enjoy this.


Regards,
Kabir

jacquesd
Posts: 10
Joined: 09 Nov 2004, 06:09

Create a Digital Clock with 4 actions in QuID

Post by jacquesd » 16 Aug 2007, 10:38

Kabir,

I would like also to play a sound each hour, how is it possible to make the expression break if minute=0 and second =0, i have tried with no success and as i have to wait each hour to test it, its a bit long to use my trial and error way :wink:
thanks again
jacques

jacquesd
Posts: 10
Joined: 09 Nov 2004, 06:09

Create a Digital Clock with 4 actions in QuID

Post by jacquesd » 16 Aug 2007, 10:57

Kabir,
second question for the cuckoo clock, i tried to put in a second text box the date day and month, it works but how do i tell QID that 0 is "monday" 1 is "mardi" on so on? same for the months of course, i also tried the date to string expression by lazyness but it displays in english and i would like to display in french and without the hours of course
regards
jacques

jacquesd
Posts: 10
Joined: 09 Nov 2004, 06:09

Create a Digital Clock with 4 actions in QuID

Post by jacquesd » 16 Aug 2007, 15:07

third question more cosmetic but useful to understand, when it's 22:02:00 my QID clock says 22:2:0 which is'nt very nice how do i get rid of this?
by the way i discover a strange apple thing, i have 10.4.10 installed but when using the function get OS info in QID it reports 10.4.9 funny no! so i think they forget to rename the update internally

Kabir(Quark)
Posts: 5
Joined: 30 Oct 2006, 23:29

Create a Digital Clock with 4 actions in QuID

Post by Kabir(Quark) » 17 Aug 2007, 02:01

Hi Jacques

To make the clock play a sound every hour you will need to add the following actions just before the last action (i.e. the run script action)

1) Apply the Control If action and select Expression from the object type field.

In the expression field type -
Date.GetMinutes()==0 && Date.GetSeconds()==0

this statement checks when the minute and second are zero i.e. every new hour

2)Now you can add the play sound action

3) Close the If condition using Control -> End if action

Now , this condition will check every second if the minute and second values are zero and play a sound every hour.

--------------------------------------------------------------------

As for the days and months , we would need to craete a script with multiple If conditions e.f. 7 conditions for the day of the week and 12 conditions for the month of teh year. This is what the script would look like:

1) Add a control -> if condition
2)Choose expression from the drop down and type the expression
Date.GetDay()==0
add another action after this and choose Expression -> set
TextBox2.Append("Sunday")
3)Close this if condition using Control -> End if action

Now simply duplicate these 3 actions (6 times) using the duplicate action button and make slight modifications for the rest of the days and you are done.

You will have 7 closed if conditions.

Please note that you would need to loop this script like the "clock" script by giving it a delay and adding the last action as run script that calls this script again. So after the last if end if condition add Delay action (300 s) and script run-> Script 2

--------------------------------------------------------------------

As for the third question , I am afraid I cant give you a work around to solve this but this is something we might want to fix in an upcoming release.

I havent checked the getOS function but if thst the case you just might have found an Apple or a Flash bug :wink:

Hope this helps.

Regards,
Kabir

Matthias Guenther (Quark)
Quarkian
Quarkian
Posts: 2490
Joined: 04 Jun 2004, 15:06
Contact:

Create a Digital Clock with 4 actions in QuID

Post by Matthias Guenther (Quark) » 17 Aug 2007, 03:17

Hi, Jacques,

[img]../../themes/default/images/icon-quote.gif"> [strong]Kabir(Quark):[/strong]As for the third question , I am afraid I cant give you a work around to solve this but this is something we might want to fix in an upcoming release.
And of course you can "fix[/img]
However, soon this will get into a coding lesson, not really what you probably want to do. If still, here's how:

(assuming your text box is called Clock)

If Date.GetMinutes()<10
Clock.Append("0")
endif
Clock.Append(Date.GetMinutes())

You need to repeat that for hours and seconds too.

YOu can also construct that using variables, however you will loose the ability to do that in one statement. Construct them bit by bit using "IF hours <10 ClockString = "0"+Hours Else ClockString + Hours" and then the same for minutes and seconds.

Whether that's the best use case for Quark Interactive Designer, I doubt it. Maybe get an SWF downloaded where somebody already created this and just load it into an SWF object in Interactive.

Best
Matthias

jacquesd
Posts: 10
Joined: 09 Nov 2004, 06:09

Create a Digital Clock with 4 actions in QuID

Post by jacquesd » 17 Aug 2007, 05:05

Thanks Kabir and Matthias for your wises answers, i'm gonna try it this afternoon, i already add a new feature to my clock, it displays screen resolution of the viewer!, in fact the expression editor is incredibly powerful for a newbie, it makes me believing i can "code" things! great
best regards
jacques

jacquesd
Posts: 10
Joined: 09 Nov 2004, 06:09

Create a Digital Clock with 4 actions in QuID

Post by jacquesd » 20 Aug 2007, 09:32

but as usual thanks again matthias & kabir, now my clock displays correctly the hours minutes and seconds ! it also beeps every hour and shows day and month by clicking the hour, i know it's a bit silly but i am quite happy with this nonsense clock
by the way very slignt bug for frenchies the expression editor does'nt accept words accented even with"" just like "fvrier"

best regards
jacques

k_ahrendt
Posts: 0
Joined: 17 Aug 2007, 14:29

Create a Digital Clock with 4 actions in QuID

Post by k_ahrendt » 20 Aug 2007, 15:21

Good afternoon gentlemen,
Thank you for this interesting idea. I have done the script and have had it play successfully in the ID page that I created it on.
Do I need to do something when I save the SWF to have it play when I place it into the project's web page? I tend to create stand-alone swfs so I can add them to my web pages as needed. But this one doesn't seem to play.
Any help will be appreciated. I'm not a programmer (I was put on earth to run them) so this is all new to me.
Kathy A.

http://www.mgtparty.org/
All Quark designed web site. Look for the blank red box in lower left corner, this is where the clock should be.

Kabir(Quark)
Posts: 5
Joined: 30 Oct 2006, 23:29

Create a Digital Clock with 4 actions in QuID

Post by Kabir(Quark) » 21 Aug 2007, 00:35

Hi Kathy

After saving the swf file , you need to use it in the web layout using get picture command. I see you have done this but I think the box is too small as compared to the size of your swf. For the swf to work properly on the web page you need to right click on the picture box and do a "Fit Box to Picture"
If this is not done then only a snapshot of your swf is exported with the web page. Doing this ensures that your swf is exported and will play on export.

Note: Make sure you do not make any other change to this picture box e.g. change its shape , size , color , frame, etc

If your swf's dimensions are too large I suggest changing the layout properties of your presentation layout to make it smaller and re-export it.

Hope this helps.

Regards,
Kabir

Locked

Return to “Expressions”