Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Rates & Deals Dreamweaver Templates Web Applications Free Tutorials About Us Contact Us
Web Design Guide > Best Web Design Tools | Web Design Ideas | Web Design Tips | Navigation Tips | Fireworks Tips | Rollover Images | Swap Images | CSS Styles Tutorial
Dreamweaver Tips | Dreamweaver Template | Server Side Includes | Dreamweaver Behaviors | Flash Tutorials > Flash Effects | Flash Sound Buttons | Sound On/Off Button
Flash Preloader | Importing External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

Flash and ASP Integration - Flash sends data to the Database

This section is most probably the easiest of the whole tutorial. It is divided into three parts:

This involves the following functional cycle to be realized:

  1. Flash sends the data from the 'Input Form' to the ASP file
  2. ASP sends the data to be stored to the database
  3. ASP sends the result of its operation (success or failure) to the Flash interface
  4. Flash sets a counter while the ASP inserts the data and shows success or failure of the operation

Note: Values or code you will have to enter are given in light blue and red Italics show specific settings to be followed by you. All ASP code can be directly cut and pasted into your file. Comments in ASP are in green.

Starting Flash Guest-Book Interface


Preparing the Flash Interface

Flash Guest-Book Send function interfaces

1. Input Form: You will have to assign variable names to the three fields shown by right clicking the respective boxes and selecting the properties option:

  • Give the following values in the variable box:
    • Name field - name
    • Email Address field - email
    • Comments field - mess
  • For all the three fields make sure that the draw border and background option is checked and the do not include font outlines option in the properties is chosen.
  • Check the restrict text length to option for all fields and set the value for the name and email address fields to 50 and for the comments field set it to 255.
  • Double click the reset button and give the action script (actions tab):
        Set Variable: "name" = ""
         Set Variable: "email" = ""
         Set Variable: "mess" = ""

    Logic: This clears what ever has been entered in the boxes
  • Double click the Send button and give the action script:
         Set Variable: "iSuccess" = 0
        Load Variables ("GuestBookSendCode.asp", "", vars=GET)
         Set Variable: "submit" = True
         Set Variable: "y" = 0
         Play

    Logic: This sends the values entered to the ASP page, sets the counter variable 'y' to 0, sets a variable 'submit' to True (to represent that the form a has been submitted) and goes to the next frame (Counter) .

2. Making the Submit Counter Interfaces: Make the interface shown in Fig(b) on your right in the next frame after 'NewEntry'.

  • Give the frame the label: 'Counter' and place the action script that follows in the actions tab for the frame on double clicking it:
          Set Variable: "y" = y+1
          If (iSuccess = 1)
                Go to and Stop ("Success")
          Else If (y > 100)
                Go to and Stop ("Failed")
          End If
    Logic: This increments the counter and depending on the value of the variable 'iSuccess' it goes to either the frame Success or Failed.
  • The two text fields should be right aligned and with different colors but same font size(to get a 3D digital display). You can of course use a single text field to make it easier for you.
  • Go to each of their properties tab by right clicking on them. Give the variable name as 'y' which as mentioned above is our counter variable.
  • Also, in their properties tab check the disable editing and disable selection options.



Fig(a): Input Form

 

 

 


Fig(b): Counter Frame

  • Make the two interfaces shown below in two adjacent frames. (You will need only the 'Successful', 'Error-Failed' texts shown and the two buttons (Return and Exit). The buttons can be programmed later when we put the whole Guest-Book together. Double click the frames one by one and give the labels:'Success' and 'Failed' respectively and in the actions tab give the action 'Stop'.

Fig(c & d): Successful and Failed Frames

Getting the Flash form to work

Making the Counter Work : Carry out the following steps to accomplish this:

Now your Flash file should appear as shown below. You have now finished the Flash interface for sending data to the database. Export your file as 'guestbook.swf' to an appropriate folder. Now create a new ASP file called 'GuestBook.asp' and place the guestbook.swf file in it.

ASP Gets the Data from the Database

Connecting to the Database and inserting data into it through ASP

<% '---------------This file is the GuestBookSendCode.asp file-------------------------

'Start Declaring all variable used by you (you can do this as you code)
Dim DBConn, strDB, strDate,strInsertSQL, strName, strEmail, strMess

'Give the Database Connection String
strDB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("dbGuestbook.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5"

'Get today's Date and the data sent from Flash (Replace is used to replace a ' with '' (2 quotes together) because a database doesn't allow insertion of strings with a single ' )
strDate=CDate(Date)
strName=Replace(request("name"), "'", "''")
strEmail=Replace(request("email"),"'", "''")
strMess=Replace(request("mess"), "'", "''")

'Give the SQL Insert Statement
strInsertSQL="Insert Into tblGuestBook (fldDate,fldName,fldEmail,fldMessage) Values ('" & strDate & "','" & strName & "','" & strEmail & "',' " & strMess & "' )"

'Open the database and insert
if strName<>"" and strEmail<>"" then
          Set DBConn = Server.CreateObject("ADODB.Connection")
          DBConn.Open strDB
          DBConn.execute strInsertSQL
          response.write "iSuccess=1" 'Send a success response to Flash
Else
          response.write "iFailed=1" 'Send a failed response coz' the name or/and email field was null.
End If

'Close the database connection
DBConn.close
Set DBConn=Nothing
%>   

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization

Services > Rapid Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Reliable Web Hosting | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Print & Logo Design Portfolio | Flash Animation Portfolio | Outsource Clients Portfolio | Client Testimonials
Rates & Deals > Web Design Rates | Custom Web Design Pricing | Logo Design Pricing | Business Card & Letterhead Pricing | Web Hosting Plans | Website Maintenance Plans