Submit Your Article Forum Rules

Poll: Is this tutorial helpful

Be advised that this is a public poll: other users can see the choice(s) you selected.

Results 1 to 5 of 5

Thread: Working With Flash MX 2004*and PHP

  1. #1
    Senior Member J_Paul's Avatar
    Join Date
    Jul 2003
    Location
    Kentucky
    Posts
    312

    Working With Flash MX 2004*and PHP

    This tutorial is going to show you a very basic method of sending information from Flash to an external PHP script. This*is merely a primer to get you working with using Flash*for forms and dynamic content.*The actual code for this tutorial can be used IN lower versions of Flash, but the actual process is written for Flash MX 2004.

    Here is the example that we are going to create - http://flashnewz.com/examples/namesubmission.html

    Creating the Flash Document

    To begin our tutorial we are going to create our Flash document. Open Flash and create a new Flash document. On the stage take your text tool and draw a text box.



    Now highlight the text box and hit F8 so we can convert our text box to a symbol. We are going to change our text box into a button. The reason we are doing this is so we can add the "Hit Enter Key" function so the user can simply hit enter rather than having to press the submit button.



    Once you have converted the text box to a symbol double click the text box so we can edit the text box. In the variable area type in "name". This is going to be used when sending information to our PHP script.



    Now go back to our main stage area, where we will add our "Hit Enter Key" actions. Open your actions panel and select your text box. In your actions panel under Global Functions/Movie Clip Controls double click the "on" and select keyPress "<Enter>".




    In the actions pane click before the } tag because our getURL command has to come before the close of the actionscript. Under Global Functions/Browser/network double click the getURL action. Now in our actions we are going to add a link to our php script, window, and method. I named my PHP name.php. Make sure that you use the GET method for this example. Here is what your actionscript should look like:



    This completes the textbox area of our FlashMovie. To add another button so the user can click as I have added in my Flash movie you simply repeat this process, but use the on (release) function.



    Now export your movie.

    Now it's time for our PHP script.*

    Since the PHP is so simple for this example I am going to paste the code and let you copy it, name it name.php and let you use it from there.

    Code:
    <html> 
    <body> 
    
    
    Hello <span class="style1"><? echo $_GET['name'];?></span>,</p> 
    
    
    As you can see, our Flash movie has sent the information you entered into the text field to the PHP script displayed here.
     
    </p> 
    </body> 
    </html>
    Notice that we used "name" in our php script to reflect the variable in our Flash movie? If you change the variable name in our Flash move we also need to change the value in our php script.

    Now upload both of them and test it out. If we did everything properly the SWF file should send the information to the PHP script, which will show the name once the user submits the data.

    If you have any questions or comments feel free to post them here. Also let me know if this tutorial is useful by using the poll at the top of this page. Thanks!
    John Paul | Studio Interactive LLC
    New 2013 Design - Website Design Louisville | Free Fireworks Templates for 2013

  2. #2
    Banned
    Join Date
    Apr 2004
    Posts
    7
    will that open browser or invoke php page into flash? if first is true, is it possible to make it behave like second, so that everything stays in flash, and how?

  3. #3
    Senior Member Markll's Avatar
    Join Date
    Aug 2003
    Posts
    615

    Well Done

    Nice tutorial. Flash is so much more than a "flashy"
    presentation tool. Hopefully this will enlighten people to it's other capabilities.

    A little project I'm working on with Flash and PHP:
    http://imageselect.us
    http://imageselect.us/indexblack.htm


    http://mtheoryit.com

  4. #4
    Senior Member J_Paul's Avatar
    Join Date
    Jul 2003
    Location
    Kentucky
    Posts
    312
    vinyl.. it goes to a seprate PHP page. The variable is simply passed from Flash to PHP such as a submit form would pass variables to a database.

    http://flashnewz.com/examples/namesubmission.html

    is the example so you can see what I'm talking about.

    ComputerMark.. thos rock.. I'm not too keen on the graphics.. but the flash/PHP and submission tools rock.
    John Paul | Studio Interactive LLC
    New 2013 Design - Website Design Louisville | Free Fireworks Templates for 2013

  5. #5
    Banned
    Join Date
    Apr 2004
    Posts
    7
    sure, i thought it is like that... what i wanted to know is if it's possible to stay only in flash - for instance, i want to make a textbox where person enter his name - when submitted, transfer it to some php page where i will check if that name is in database and based on the result output "passed" or "not passed" in the flash movie label, but WITHOUT any external browser page opening - just flash.

Similar Threads

  1. importing sound w/ video in Flash MX Pro 2004
    By webdiva in forum Flash Discussion Forum
    Replies: 0
    Last Post: 02-05-2005, 01:08 PM
  2. Flash MX and MX 2004 and also Swift 3D
    By dan_bradshaw in forum Flash Discussion Forum
    Replies: 2
    Last Post: 07-21-2004, 01:16 AM
  3. Flash site designed with MX 2004
    By sxd in forum Flash Discussion Forum
    Replies: 1
    Last Post: 06-18-2004, 02:37 PM
  4. Looping Movies With Flash MX 2004
    By J_Paul in forum Flash Discussion Forum
    Replies: 1
    Last Post: 04-28-2004, 08:54 AM
  5. Flash MX 2004 - 2 versions.. good or bad??
    By J_Paul in forum Flash Discussion Forum
    Replies: 4
    Last Post: 09-10-2003, 11:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •