Johnny G Junior's NoteBook Treasures: August 2008

Thursday, August 14, 2008

Creating Radio Buttons in Flash

Lets Play with RadioButtons today...

First go to window Menu and pull up Components. In the componests window, lets drag onto the stage a RadioButton.

Each one of these radiobuttons components are MOVIECLIPS with Pudding in the middle. (the pudding being the predefined fields if you know what i mean...

First, we give each radiobutton an INSTANCE NAME.

in this example, im going to name it mcQuestion1 <-- (mc - MovieClip)

Every other Radiobutton im going to name the instance name the same but i will just change the number. (Note - this is just a name... its not grouping these buttons together).

Now, lets add DATA, GROUPNAME and a LABEL. in a new layer called ACTIONS, lets put a framescript....

mcQuestion1.label = "Do you like Puppy's?" = "I like Puppy's";
mcQuestion1.groupName = "questions";

mcQuestion2.label = "Do you like Pizza?" = "I like Pizza";
mcQuestion2.groupName = "questions";

Label - changes the label of the radiobutton
Data - changes the value of the radiobutton
groupName - keep all the radio buttons together as a group.

to display the results of a selected button, you can store the selected data into a variable of your choice and call upon it when you want. Lets make a var. called "Answer". (var Answer;)

Answer = questions.selectedData;

Format - GROUPNAME.selectedData (this will give you the result from the radio buttons)

you can now make a button and have it do something like this

on (release){
selectedButton = GROUP.selectedData; // selectedButton is a var.

any questions, hit me up.