-
radio button component
i have a couple of radio buttons in a scene
when i select radio button a, i want to move the playhead to frame "a"; when i select radio button b i want to move the playhead to frame "b";
radio buttons:
changehandler: radioButtSelected
on frame 1 i have the following code:
function radioButtSelected(obj) {
if(obj.getSelectedItem().label=="a"){
gotoAndStop("a");
}
if(obj.getSelectedItem().label=="b"){
gotoAndStop("b");
}
}
i used the above code succcessfully with a dropdown menu, and i was hoping it'd work with the radio buttons. i've tried using data instead of label but i'm getting nowhere.
any help is very welcome
cheers
jose gonzalez
-
Try this
For radio buttons in the properties panel they have something called a group name. All the radio buttons that are choices to a particular question would all have the same group name. So lets say I have 5 radio buttons that are all possible answers to the question:
What color is the White House?
1)Red
2)Blue
3)White
4)I am a moron
5)Off White/Baige
So let's say we named our "group name" whiteHouseGroup. (ok, here comes the code)
The folowing code will get the data for whichever box is checked:
whiteHouseGroup.getData();
So if radio button #4 is checked whiteHouseGroup.getData(); would return 4 (or whatever you put to be in the data field in the properties panel)
So now we fix your code a bit to fit the new code:
function radioButtSelected() {
gotoAndStop(whiteHouseGroup.getData());
}
That should do the trick and be much easier to write.
Good luck I hope this helped.
-
awesome
that was very well written, and the neat code made something click in my head (the way you fished out the data in the 'goto' line)
i really appreciate that
jose gonzalez
-
I'm glad it worked out for you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|