Document Sample
ANM_CtSC Powered By Docstoc
					        American New Media Client to Server Connector
                     ANM_CtSC V 1.0.0

What is it?

        The American New Media Client to Server Connector is an embedded Flash
object that acts as a conduit for data between Javascript and PHP. This allows a Web
developer to create Web pages that transfer data both ways without having to leave or
refresh the page.

Do I have to use Javascript and PHP?

         There is no particular reason why the ANM_CtSC could not be used with most
any server side and/or client side scripting languages (VB script, ASP, Perl, and other
CGI technologies). The ANM_CtSC has examples and include scripts designed for
Javascript and PHP. If you would like a version suitable for a different technology, you
may purchase the professional version. This version of the ANM_CtSC allows for
commercial use and shows the mechanism for adapting other technologies. In the case of
client side script other than Javascript, contact us and we will send you the appropriate
version of the ANM_CtSC object.

How does it work?
        The American New Media Client to Server Connector uses the following data
           1. Send data from the Javascript in your Web page;
           2. The ANM_CtSC object passes the data to your PHP page;
           3. The PHP page processes the data and optionally returns data back to the
              ANM_CtSC object;
           4. The ANM_CtSC object passes the returned data to the Javascript in your
              Web page and calls a Javascript function defined by you.

How do I use it?
        The American New Media Client to Server Connector is comprised of three
components: a Flash object, a JavaScript object, and a PHP include document. To use the
tool you must have a working knowledge of PHP and Javascript. No knowledge of Flash
is required. The steps to utilize the software are:
            1. Create a Web page and embed the ANM_CtSC Flash object.
            2. Include the ANM_CtSC Javascript component and write your own
               Javascript functions to generate data and use the Javascript component to
               send it to the server. There are many good tutorials on Javascript available
               on the Internet.
            3. Include the ANM_CtSC PHP component and write your own PHP to
               process the data received. You can store the data in a file or database or
             perform any task of which a scripting language is capable. There are
             many good tutorials on PHP available on the Internet.
          4. Use the included PHP component to return data to your Web page. The
             ANM_CtSC software will call the Javascript callback function that you
             have created and specified which you may use to handle the data.

Flash Component

    Every page that employs CtSC must include the following code to embed the
ANM_CtSC Flash object in that page:

<OBJECT classid="clsid:D27CDB6E -AE6D-11cf-96B8-444553540000"
ersion=6,0,0,0" WIDTH="80" HEIGHT="20" id="ANM_CtSC" ALIGN="">
<PARAM NAME=quality VALUE=high>
<EMBED src="ANM_CtSC.swf" quality=high bgcolor=#FFFFFF WIDTH="80" HEIGHT="20"
NAME="ANM_CtSC" swLiveConnect=true ALIGN="" TYPE="application/x-shockwave-

JavaScript Component

        Every page that employs ANM_CtSC must include the following code to include
the JavaScript object in that page:
        <script src=”ANM_CtSC_js_utilities.js”></script>

        This code will allow one to use the ANM_CtSC_Obj JavaScript object. This
object is the engine through which one communicates to a PHP script. To create an
instance of the object, use the Create_CtSC_Obj function.
     Arguments: obj_name – name of the ANM_CtSC_Obj that you wish to create.
                   script_name   – URL of the PHP script to which you wish to send
                   callback_function – The function that will be triggered when the
                   ANM_CtSC data is returned to the Javascript page. Do not use
                   parentheses in the callback_function name. Do not use parameters in
                   the callback_function. i.e. a function:

                   // Begin example callback_function

                   Var myVarName = “thedata”;
                   Alert(newObj .get_var_val(myVarName));
                        // add any Javascript code you want…

                   // End example callback_function


ANM_CtSC_Obj Object Listing

Method                                Description
                                      Add a variable to be sent to the PHP script.
add_send_var(var_name, var_val)       add_send_var(“t est var”,”ex ample”) will send a variable
                                      named test var with the value “example”
clear_send_vars()                     Empty the list of variables to be sent to the PHP script
set_script(script)                    Change the script the web page will communic ate with
send()                                Send the prepared information to the P HP script
                                      Get an array of the names of variables that the PHP script
get_var_names()                       returned
                                      Get and array of the values of the variables that the P HP
get_var_vals()                        script returned
                                      Get the value of a specific variable that the PHP script
get_var_val(var_name)                 returned
                                      Get the value of the error_msg (if any) sent from the PHP
get_error_msg()                       script.

PHP Component

      Every script that employs CtSC must include the following code to include the
PHP functions in that script:

        include “ANM_CtSC_php_utilities.php”;

      This include file will give you two functions to use in your processor script
ANM_CtSC_read()    and ANM_CtSC_write(). The former reads the transmissions form the
web page and the latter sends responses back to the web page.

        ANM_CtSC_read() accepts no parameters and returns an associative array that
holds the name and values sent by the ANM_CtSC_Obj on the web page.

      ANM_CtSC_write($send_arr, $error_msg) accepts two              optional arguments.
$send_arr is a hash array of the variables that you wish to send to  the ANM_CtSC_Obj.
Which is to say that the key is the “name” of each variable, and the value is the “value” of
each variable. For example if you wanted to send two variables (name = “John Doe”, and
title = “CEO”):

// begin setting variables and performing the write command

        $send[name]= “John Doe”;
        $send[title]= “CEO”;

// end setting variables and performing the write command

Note: You should always perform the write command when your PHP script completes
operation, even if you have no data to send back.

If used, $error_msg is a string that sends an error message to be displayed in the
ANM_CtSC Flash object. This variable is especially useful in debugging. For example

// begin setting variables and performing the write command

        $send[name]= “John Doe”;
        $send[title]= “CEO”;

        $myerror = “database query failed.”;

        ANM_CtSC_write(“”, $myerror);

// end setting variables and performing the write command

Note: When issuing the write command with no data you need not set a parameter. When
sending no variable data with an error_msg, you should declare the first parameter as
empty using quotes..

       As your PHP script is called by the Flash object, none of the PHP screen output
functions have any visible effect. However, part of the data transmission system uses
some of PHP’s screen output functionality. Please do not output to the screen in your
PHP scripts as it causes the ANM_CtSC system to fail. This includes error messages.

        Note: Your PHP script will be launched anew each time the ANM_CtSC_Obj sends a
transmission. Any variables that were set in the previous running of your script will be forgotten
on each transmission. To remember data from transmission to transmission your script should
employ techniques such as session variables, cookies, or database storage.

Where can I get help?
ANM_CtSC Personal Version 1.0.0
       Contact American New Media via e-mail only to report bugs, or request paid
support. We do not offer free support for the personal version.

ANM_CtSC Professional Version 1.0.0
       Contact American New Media via e-mail or Web to request support. Support
does not include teaching you how to use Javascript or PHP or make a Web page.

Shared By: