Using
Components to Create a Form
written by ilyas usal aka pom
This tutorial is more or less a sequel to
Kirupa's tutorial about the
scrollbar and mine about the
listbox. Please read them carefully before attempting this one.
I will show you in this tutorial how to:
set up the form with 6 of Macromedia's components
get the input from the user with Actionscript
change very easily the looks of your form using Actionscript
We are going to make a form asking for information about the user. He will
answer a certain number of questions, and when he presses the submit button,
we will get all his answers, and go to an answer frame that processes the input data.
This is what the form is going to look like when everything
is finished:
[ fill the form and press the
submit button ]
To see more easily how it works, we are going to use the trace function to display in
the output window what the users inputs.
Creating the form:
-
The general layout
Create a new movie in Flash
MX. Set the width and height to 500. You can choose a background color,
a background image, anything you like. I put a yellow background (#FFFF00).
Name the first layer
components. Also add 2 layers
in the timeline. Name them code and labels.
In the labels layer, add a keyframe on frame 5 by pressing
F6 and add a frame on frame 10 by pressing F5. Add a keyframe
on frame 5 in the code layer too. Your timeline should look like this:

[ the
timeline ]
-
Actions and labels
Open your Actions panel. Select the first frame of the
code layer and put the stop();
action. Do the same in frame 5.
Now open the Properties panel. In the Labels layer,
select frame 1 and enter the frame label form. In frame
5 enter the frame label result. Your timeline should
now look like this:

[ the
timeline again ]
-
The components
All the components are going to be added in frame 1 of the
components layer.
-
Drag and drop a radio button in the top left end of the scene.
Then press Ctrl and drag it to duplicate it. Do it once more to have 3
radio buttons.
-
Drag and drop a combobox on the scene under the radio buttons.
Drag and drop a listbox.
-
Drag and drop two push buttons.
-
Drag and drop a check box and then duplicate it 5 times like we did
with the radio buttons.
-
Put an input text and drag and drop the scrollbar component on it.
This is pretty much how the form is going to look like so try and make it look
good. Personally I use the properties panel all the time to place precisely my objects on the
scene.
What we have to do now is populate the components, and get the input of
the user. We will do this with Actionscript. Click the Next
Page link to proceed with adding the Actionscript.
|