 |

Form2Flash

Binding Flash4 to forms
Flash 4 has a number of features that, when combined, can do something very
similar to what Form2Flash does. On this page I give you a javascript that
will load all the fields from a form into Flash 4. You can then use
the input in Flash 4 (using action-scripting) to your heart's desire.
- Freeware
- Javascript, no cgi-bin necessary
- Automatically imports all fields from a form
- Flash 4 only
- Netscape and Explorer
Also see the following page at Macromedia, for other methods of getting variables
into Flash:
Different approaches to setting variables in a Flash movie
|
Basic
A new feature in Flash 4 is that it can directly accept parameters
on it's commandline. All you have to do is specify a Flash movie as the "action"
of a form. The fields in the form become available as variables in your movie.
For example:
<form action="Sample.swf">
Your name: <input type=text name="UserName">
<input type=submit value="Submit">
</form>
This will show the following form (try it now!):
After you click submit then the movie "Sample.swf" will be displayed full-screen,
with your name in black on a yellow bar. The sample is as basic as possible
for demonstration purposes.
You can download the "Sample.swf" file below, see the "download" section.
|
Advanced
A disadvantage of the "basic" method is that the movie
will always be displayed full-screen. You cannot control the size of the movie,
or other things like quality and start/stop. This is why I have developed the
following Javascript. You can use it to bind a form to a Flash movie
while retaining full control over the movie.
The Javascript must be added by hand to the html generated by Flash.
For example:
<form action="template.html">
Your name: <input type=text name="UserName">
<input type=submit value="Submit">
</form>
This will show the following form (try it now!):
The "template.html" contains the normal Flash startup as generated by the Flash
editor plus the Javascript that will pass the "UserName" field
to the movie. The movie used is
exactly the same movie as used above in the "Basic" example.
|
Download
The download contains the javascript template, called "template.html".
Also in the download is a ready-to-run example, consisting of "form.html",
"Sample.fla", and "Sample.swf". These are exactly the same as used by the
example on this page.
Download the template (24Kb)
|
Using
- Copy the template.
Give the copy any name you like.
- Create a form.
Use your favorite html-editor and create a form with input fields.
Set the 'Action' of the form to the copy of the template.
Give every field in the
form a unique name, they will later be used to match with fields
in your Flash movie.
For example:
<form action="template.html">
Your name: <input type=text name="UserName">
<input type=submit value="Submit">
</form>
- Create a movie.
Use the Flash editor and create a new movie.
Create variables in your movie to receive the input from the form.
There are many ways to do this. See the Flash documentation for more
information.
For example: in the form above we created a field with name "UserName".
Open Flash, and create an empty text-box in the very first frame of
the movie. Then open the properties of that text-box, and set the
'Variable' property to 'UserName'.
- Edit the template and insert your movie.
Use the 'Publish' function of the Flash editor to generate the html
you need. Cut and paste the html into the template (see 'BEGIN OF INSERT').
Then add the following parameters by hand:
<OBJECT ID="Form2Flash" ... >
<EMBED NAME="Form2Flash" SWLIVECONNECT=true ... >
- Test it.
Upload the form, your Flash movie, and the template to your webserver.
Any directory (folder) is fine. Open the form in your browser and enjoy!
|
Known problems
- Object doesn't support this property or method
- The problem is limited to Internet Explorer 5 on Macintosh.
I have no solution at this time.
The Basic method works fine, only the Advanced method has a problem.
|
|
 |