Sometimes you need to interact forms in Flash with the Cold Fusion Server Technology. And you think: Ohh my god, what I have to do now to interact it?

The answer is here:

If you know a little bit of action script your problems are decided. Whit this tutorial you will be able to make a little form to insert data indo an Access database.

First we will have to create our database:

Table name: Users
Fields: idUser(AutoNumber - Primary Key) - Name(Text) - Email(Text) - ADDS(Memo)

Now we have to create our form interface into Flash. Something like this:

Note that in the fields I've put the instances, witch will change for ever fields.
Eg: The field name will have to have the instance var as name, and the same to email and Adds.

Then we created a form with the instance names as "Name" - "Email" - "Adds". Now we have to attribute actions to the button next and to the frame.

Into the button next we have to put:

on (press) {
//Send the variables to the CFML page, this is the secret of all
loadVariables("insert.cfm", "_root", "POST");
}
//Send us to another keyframe
on (release) {
gotoAndPlay(2);
}

And into the frame actions we have to put:

stop();
//It will finish the action until the button is not clicked

Did this, now we have to create another keyframe at number 2 in the timeline.
Into this we can create the gratefulness page:

This page have a button, that will have the action:

on (press) {
// On pressed it will sent to the 1º frame
gotoAndPlay(1);
}

And in the frame's action we'll put the same of the first:

stop();

Then, we will construct the insert.cfm page:

<cfquery datasource="YourDSN">
INSERT INTO USUERS(
                       NAME,
                       EMAIL,
                       ADDS
                   )
                   VALUES(
                       '#NAME#',
                       '#EMAIL#',
                       '#ADDS#'
                   )
</cfquery>

Save it as insert.cfm, publish your flash as swf and try it.

That's it, it's that simple to add data into your database with flash.

Questions, comments...mail-me
Thanks for your attention,
Marcos Placoná

About This Tutorial
Author: Marcos Placoná
Skill Level: Advanced 
 
 
 
Platforms Tested: CF5
Total Views: 203,563
Submission Date: February 03, 2003
Last Update Date: June 05, 2009
All Tutorials By This Autor: 4
Discuss This Tutorial
  • my problem is i have three fields with 8 empty rows among three (From time,To time,Employee(dropdown->vales are getting from DB))if any one field is empty then the values are drifting to up ,will please give me the solution for this.

  • It still works like a charm here, and should work on CF5 as well. Cheers

  • I am new to Flash. I want to know how Flash connect with server file (CFM). I do we define the DSN and collect data in CFM file. Regards, Vinod Bora

  • I did not have any problems with this code. You might want to find out what version of Coldfusion your dev server is running. Mine is ruming MX7.

  • See coding: I don't get the messages sent to my email address. Code in Flash for Submit button on (release) { if (username.text == "" || email.text == "" || wedding.text == "" || comments.text == "") { getURL("javascript:alert('name, email, wedding date, and comments are needed');"); gotoAndStop("feedbackform"); } else { cfData = new LoadVars(); cfData.onLoad = function() { _root.gotoAndStop ("results"); }; cfData.username = _root.username.text; cfData.email = _root.email.text; cfData.weddingdate = _root.wedding.text; cfData.comments = _root.comments.text; cfData.sendAndLoad(sendfeedback.cfm, cfData, "POST"); _root.gotoAndStop("wait"); } } Code for sendfeedback.cfm sendfeedback.cfm #form.username# #form.email# #form.wedding# #form.comments#

  • my question is "how it passes the variable to cold fusion page"..it seem's it didn't pass the variable...really need u help to clearify it again..maybe better with example... thanks for ur time....

  • Hi there, How it passes the variable to the cfm page???and with out cfparam stuff.. even if you put the cfparam .Is the variable value is posted to the page??? Please clarify this tutorial again please. Thanks. Mayoorathen

  • If you have doubts, you can contact me in my new e-mail. Regards, Marcos Placoná

  • the above code didnt work.i must have gone wrong somewhere....can someone tell me the code for how to create write into the database file while i write into the input boxes in flash and then retrieve information from the same database thru dynamic text boxes

  • Hello, I am confussed how to enter the YourDSN in insert.cfm file. Please provide an example. Regards Bimal email b_c_singha@yahoo.com

Advertisement


Website Designed and Developed by Pablo Varando.