First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Patrick Mineault

Step 1: Building a single radio button

I know this will sound stupid, but let's start by analyzing how a radio button is made. Trust me, there are many elements which I'm sure you haven't thought of.

Well, first and foremost, a single radio button has two states: on and off. It also has a label, that is, a small blurb of text that sits there on the right and tells you what the button is for.

A radio button can be selected by clicking on it, but it can't be unchecked by clicking on it again; you have to select another option. And that's where the concept of dependency comes in: you can't have a radio button by itself. It doesn't make sense. The radio button must be part of something bigger, an option list, and it must be able to communicate with it.

So we'll start by creating a single radio button, which we'll put in relation to others later on. Create a new movie clip and name it "single radio button". Create two layers in it: states and label. In the first frame of the states layer, you should put a picture of an unclicked radio button, and in the second frame, the picture of it clicked. In my case, I simply used screenshots of radio buttons in different states, but you may use whatever you want.

Now in the first frame of the "label" layer of your movie clip, create a dynamic text box, about the length of 25 or so characters of text, and choose "label" as the variable name in the text options panel.

Your movie clip should now look like this:

Simple enough right? The first frame acts as the unselected radio button, and the second as the selected button. As you've probably guessed by now, we'll simply switch between these two frames in order to select and unselect our radio buttons.

Now that this is done, get out of that movie clip and go into your main timeline. Drag an instance of the "single radio button" and drop it into the first frame of your main timeline. Name it "radioButton0" in the instance properties window. That's it for the graphics part.

Wait a minute? That doesn't make sense, you say, I want more than one frigging radio button!!! Touché. The beauty of the script we're going to make is that it will be self-constructing: the script itself will make the radio buttons, not ourselves. So it will simply use this button as a template for all the others. It will even create text labels for each of them!

This will make updating your movie much easier, since you won't have to touch the graphics part. Instead, you'll just modify a few lines of code and the script will do all the dirty work for you. Meanwhile, you can peruse half-naked in your home drinking cheap tequila while your boss thinks you're doing work. That's right, better living through actionscript. Who would have thought?

» Level Intermediate

Added: 2001-12-05
Rating: 6.8 Votes: 30
(10 being the highest)
» Author
Patrick is a bored, bored 19 year old guy in desperate need of a girlfriend. He enjoys Flash, helping other people by writing tutorials, and has an almost creepy affection for blue squares. Come on girls, what are you waiting for?
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.