Search Tutorials
Step 1: Building a single radio buttonI 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?
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|