Post 1 made on Tuesday January 15, 2008 at 13:40 |
Deaky Long Time Member |
Joined: Posts: | August 2007 53 |
|
|
I have a button on my page that is either play or pause. I track the state of it with variable p. When I press the pause button it changes variable p = 1 and emits the pause command to my sky box. Next time I press it it changes variable p =0 and emits the play command to my sky box.
The button image is also controlled by variable p. Is it a good idea for the page script to run every second to detect that the value of P has changed upon a button press and change the button image accordingly or should I add the script to change the button image to the button script it's self. This seems a messy way to do it because I have the firm buttons copying the action of the play pause button which means I will have to copy the code to the firm button too. Before I know it I will have bits of code all over the place.
Alternatively is there a way to force the page to refresh after I have pressed the button??
Thanks
|
|
Post 2 made on Tuesday January 15, 2008 at 16:43 |
Barry Gordon Founding Member |
Joined: Posts: | August 2001 2,157 |
|
|
No, put the code that does the work at the activity level as a function and call it from the two places you mentioned. I do not see why you need the additional variable p, just look at what the label says and decide what to do including changing the label and or image. Wherever you initialize p, intitial the buttons label and or image. That puts one line of code at the button and a function callable from any page of the activity. I would probably store the two images for pause and play as the normal and pressed images of a button on a hidden resource page.
|
|
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.