PDA

View Full Version : [F8] Using a variable for the label value of a radio button component


lporiginalg
07-06-2007, 09:48 PM
Hi guys I am working on a quiz/survey in flash where all the questions, answers and values etc are stored in an external XML file. I thought I could save a bit of time by using radio button components but I'm not sure how I can set the label value of this component to be read as a variable so that it will load the proper 'answer' for the question.

So for example I am declaring my variable using something like this when the XML is read:

answer1 = xmlDoc_xml.firstChild.firstChild.nextSibling.first Child.nextSibling.firstChild.nodeValue;


but how do I tell the component to use answer1 as the label so my text will show up next to the radio button properly. If I'm not being clear enough let me know and if you can help me out on this thanks very much.

Lyndon

tg
07-06-2007, 10:41 PM
you just want to modify the label of a radio button?
not sure i get what your asking... but try:

myradiobutton.label=answer1;

lporiginalg
07-06-2007, 10:45 PM
yup exactly what I needed, thanks mate.

lporiginalg
07-07-2007, 12:03 AM
now for some reason tho the radio buttons aren't working properly in that selecting a new answer for groupName 'question1' doesn't deselect the previous answer :S

If anyone wants to take a look and tell me what I'm doing wrong I'm sure we can all have a good laugh at my expense :)

lporiginalg
07-07-2007, 01:38 AM
well i got it working just by declaring the groupName(s) at the same time as the labels in actionscript.


question1_txt.text = question1;
q1a1.label = q1a1_label; q1a1.data = q1a1_label; q1a1.groupName = question1;
q1a1_subtext_txt.text = q1a1_subtext;
q1a2.label = q1a2_label; q1a2.data = q1a2_label; q1a2.groupName = question1;
q1a2_subtext_txt.text = q1a2_subtext;
etc etc

lporiginalg
07-21-2007, 09:20 PM
ok I have a new problem with this same file now, is there a way to have radio buttons be in the same group without being in the same instance on the stage? I have each radio button in a seperate movie clip container but not sure how to set the groupName paramater so that only one button can be selected at a time. Let me know if I'm not being clear enough, help is very appreciated, thanks.

Lyndon