PDA

View Full Version : Maintaining checkbox states between pages


kmartin7
12-03-2004, 02:13 PM
I have a checkbox on each page that allows the end user to turn off background music if checked. I am trying to maintain the checkbox state between pages, and am having difficulty maintaining the states when a new page is jumped to. I don't know where to place the code; on preload, on show, on click? It seems I have tried everything. Please help. Here is the 7th iteration of code, placed in the on click and on show events for each page:

isChecked2 = false;
isChecked2 = Button.GetState("checkbox");
if (isChecked2 ~= 1) then
Button.SetState("checkbox", BTN_UP);
Button.SetState("checkbox2", BTN_UP);
Audio.Play(CHANNEL_BACKGROUND);
isChecked2 = false;
else
Button.SetState("checkbox", BTN_DOWN);
Button.SetState("checkbox2", BTN_DOWN);
Audio.Stop(CHANNEL_BACKGROUND);
isChecked2 = true;
end

TIA,

Kurt

sside
12-03-2004, 03:40 PM
Page On Show

if (button == 0) then
Button.SetState("Button1", BTN_UP);
elseif (button == 1) then
Button.SetState("Button1", BTN_DOWN);
end


Button On Click

if (Button.GetState("Button1") == 0) then
button = 0
elseif (Button.GetState("Button1") == 1) then
button = 1
end


Place the code in every page (on show) and button (on click) and add the rest of the code for the music to be played or stopped

Note: I'm describing here only how to maintain the button state. This is what i understand you're having problems with...

sside

Josué Alba
12-03-2004, 09:22 PM
Hey I made an example for you

kmartin7
12-06-2004, 12:50 PM
Good stuff, Jose'! Thanks!

tsbpd
12-06-2004, 02:09 PM
I was working on something similiar today for a project. Thanks Jose!