Jump to content


remembering check box = selected when going back a frame


  • You cannot reply to this topic
10 replies to this topic

#1 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 31 October 2006 - 06:38 AM

hey all,

i'm trying to have my checkboxes and radio buttons to be (if checked when the user hits the button and goes to a different page...when they return to the previous page(currentframe) they will still be selected or checked.)

any ideas how to do this or tuts??

cheers peeps :o

#2 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 31 October 2006 - 03:37 PM

Well, you can do radio buttons through variables (aswell as checkbox's, but I'll just show you radio buttons for the moment). So in your first frame, state a variable like this:
var checked:Number;
Then, on the frame with the radio button's, inside each radio button (you could just use 1 movieclip and copy and paste) add a new keyframe. On the first keyframe, make it not selected (so no dot), and the second, make it selected. Give each radio button an instance name beginning with radio, then a incrementing number after. So radio0, radio1, radio2, radio3, and so on.

On the frame with the radio button's on the main timeline, add this code:
var rbArray:Array = new Array("radio0", "radio1", "radio2", "radio3");
var totalRadio:Number = 3;
onEnterFrame = function() {
for(var i = 0; i <= totalRadio; i++) {
var radioVar = _root["radio"+i];
radioVar.i = i;
if(radioVar._name == rbArray[checked]) {
radioVar.gotoAndStop(2);
} else {
radioVar.gotoAndStop(1);
}
radioVar.onRelease = function() {
checked = this.i;
}
}
}
And there you go. I wrote this from the top of my head, so I hope you dont have any problems with it.

#3 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 31 October 2006 - 10:33 PM

wow thanks for that :D d4rkston3 i really appreciate it...as i'm sure that it is very close to what i need...i can't seem to work it into what i have already...due to the fact that i already have listeners going from them and i am calling them on the main timeline so they must stay there...also its a whole mumbo of code :S:S

but would it be possible to basically have it with your code...doing the following if "radiobutton1/checkbox1" is selected on frame 25 when user hits the view results page it shows the new content (not important) and when they return (important) to the previous page using (_currentframe) method it will still be selected or deselected depending on what the user has done before viewing the next page.

i have tried this from listeners on the first page and trying to call it from the back button on the second page...but with no luck

but thanks again!! 4 your help i'm sure its really close

#4 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 31 October 2006 - 11:54 PM

All you need to do is on the 25th frame, use this:
if(checked == undefined) {
//trace("Select a radio button!");
} else {
//trace("You selected radio button "+checked);
}
Thats all there is to it.

#5 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 01 November 2006 - 12:28 AM

it doesn't recognise it when i have that code on their it just recognises it as undefined even when selected...for some reason....also should i have any code on my back button which is on frame 25?
• the back button goes back to frame 3.
• radio buttons are on frame 3

#6 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 01 November 2006 - 12:40 AM

 	if (q1.selected == true){
	q1.selected = true;
} else if (q1.selected == false){
	q1.selected = false;
}

can i have something like this on the back button?? where "q1" = radio button group of all my radio buttons??

to me this is saying if any of my radio buttons is selected then show it as selected when i go back to the buttons else if they are not selected then show them as false...i know this is probably very wrong but i feel its a start and mayb close.

what do you think can it turn into something working lol??

ps. Thanks for the help so far :D

#7 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 01 November 2006 - 02:04 AM

Well, what you suggested would made the script pretty big, since you have to make so many variables. I'm not sure what problem you're having with the script I gave you. I tried it out myself, and it works perfectly. Here is the .fla you can download:
http://www.flashimpu...adiobuttons.fla

#8 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 01 November 2006 - 04:44 PM

cool yeh its working fine in your .fla i'll have a little play and see if i can get it working on mine...Thanks heaps for the help :ph34r:

#9 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 01 November 2006 - 04:53 PM

ahh i see know...you have used two images for radio button...i'm using a component should that matter or should the principal be the same??

#10 °•Guru•°

    Young Padawan

  • Members
  • Pip
  • 73 posts
  • Gender:Male
  • Location:Australia, Sydney

Posted 01 November 2006 - 05:13 PM

with your variable radioVar.onRelease....is this button instance or??

#11 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 01 November 2006 - 11:37 PM

View Post°•Guru•°, on Nov 2 2006, 08:53 AM, said:

ahh i see know...you have used two images for radio button...i'm using a component should that matter or should the principal be the same??
No the component is different.. I dont really use it because I dont really have any use for them.

View Post°•Guru•°, on Nov 2 2006, 09:13 AM, said:

with your variable radioVar.onRelease....is this button instance or??
The variable radioVar is a variable that holds the instance name of all the radio buttons (radio0, radio1, radio2, and radio3). I've made the instance name by adding i to the word radio. That looks like radioVar = _root["radio"+i];
So basically I'm controlling all the radio buttons with just one variable. Thats how for loops are useful.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users