|
|
|
Philips Pronto Professional Forum - View Post
|
|
|
|
|
|
|
The following page was printed from RemoteCentral.com:
Help to make this script show/not show a...
| |
|
Topic: | Help to make this script show/not show a widget This thread has 6 replies. Displaying all posts. |
|
Post 1 made on Sunday February 22, 2009 at 08:39 |
Aarestrups Long Time Member |
Joined: Posts: | January 2009 37 |
|
|
Hi all, I have this little script running on a page:
var blink = widget("Michrophone"); var i1 = 2; blink.visible = true; Activity.scheduleAfter(1000,UpdateTimer1); function UpdateTimer1(id) { i1--; if (i1>0) { Activity.scheduleAfter(1000,UpdateTimer1); blink.visible = false; } else { blink.visible = true; } }
The idea is to have the Widget "Microphone" to flash… Now this script only do as follow: show - not show – show… and then it stops. How can I make it continue to flash for some X seconds?
\Allan
|
me, |
|
Post 2 made on Sunday February 22, 2009 at 14:57 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
Allan,
Did you try increasing the value of the i1 variable to something larger than 2?
If you have, then I must be misunderstanding what you want. You could also use 2 variables, one to track flash on/off state and one to track timing. That is indeed more complex and your script above is already overkill.
For example, your lines blink.visible = (where you specify true or false); could be replaced with blink.visible = !(i1 % 2)
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
OP | Post 3 made on Tuesday February 24, 2009 at 03:51 |
Aarestrups Long Time Member |
Joined: Posts: | January 2009 37 |
|
|
Hi again,
That I need is a widget to blink/flash to attract attention to the user.. If I increase the i1 value the “not visible” state will just be on for more second before ELSE kick in -and thus the visible state. I might be doing some overkill here – I’m not a programmer :-) just having some fun with my TSU9400…
That I would like is that the widget should flash som 10 times, while NOT looking the GUI, and then after some time a Page jump to HOME.
|
me, |
|
Post 4 made on Wednesday February 25, 2009 at 13:59 |
Rusty Fobe Long Time Member |
Joined: Posts: | December 2008 47 |
|
|
Here is a solution: I will also post is as a utility for general use, when I made it proper for that use. I've put this in the activity script. You can check what's happening in ProntoScript console. Rusty
function blink(blinkData) { System.print(blinkData[0]+" "+ blinkData[1]+" "+blinkData[2]) System.print(blinkData[1]%2);
widget(blinkData[0]).visible=(blinkData[1]%2) ? true:false;
if (blinkData[1] > 0) { blinkData[1]--; Activity.scheduleAfter(blinkData[2], blink, blinkData);} }
blink([ "M", 10, 333]) // resp tag, blinkQty, frequency
|
|
OP | Post 5 made on Wednesday February 25, 2009 at 14:30 |
Aarestrups Long Time Member |
Joined: Posts: | January 2009 37 |
|
|
Hi Rusty.. It works beautifully! This stuff looks like a real piece of programming - not like my humble attempt. Many thanks!
|
me, |
|
Post 6 made on Wednesday February 25, 2009 at 14:46 |
Rusty Fobe Long Time Member |
Joined: Posts: | December 2008 47 |
|
|
Hi Allen, thanks, here is the version that I will post as utility. Rusty
function blink(blinkData) { // makes a widget blink for a given number of times at a given frequency // blinkData = [widgetTag, blinkQty, blinkFrequency] this.widgetTag=blinkData[0]; this.blinkQty=blinkData[1]; this.blinkFrequency=blinkData[2];
widget(widgetTag).visible=(blinkQty%2) ? true:false;
if (blinkQty > 0) { blinkQty--; Activity.scheduleAfter(blinkFrequency, blink, blinkData);}
|
|
OP | Post 7 made on Wednesday February 25, 2009 at 15:00 |
Aarestrups Long Time Member |
Joined: Posts: | January 2009 37 |
|
|
It makes sense to me, at least the description / instruction, so I think others could use it easily,.
|
me, |
|
|
Before you can reply to a message... |
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now. |
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.
|
|
|
|