PHP/Flash Intergration

Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default PHP/Flash Intergration

    Hello, I've been struggling with this for ages now, so it's time I asked for
    help. I'm setting up a shopping cart in Flash, using PHP to process the
    information and store/retrieve from a MySQL database. I can add items to the
    cart and display them, no problem, however I can't work out how to update the
    quantities of items in the cart (other than adding more of that item from the
    item page). I can do it using just PHP, but I can't work out how I can get
    ActionScript to send the same string as a HTML form. I'm using a HTML form that
    looks like this as a template:

    echo " <tr>
    <td align=\"left\">{$row} {$row} {$row}</td>
    <td align=\"left\">{$row}</td>
    <td align=\"right\">\${$row}</td>
    <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty}]\"
    value=\"{$_SESSION]}\" /></td>
    <td align=\"right\">$" . number_format ($subtotal, 2) . "</td>
    </tr>\n";

    which returns the information submitted back to the same page, where the
    information would be updated based on what the user had entered, something like
    this:

    if (isset ($_POST)) {
    foreach ($_POST as $key => $value) {
    if ( ($value == 0) AND (is_numeric ($value)) ) {
    unset ($_SESSION);
    } elseif ( is_numeric ($value) AND ($value > 0) ) {
    $_SESSION = $value;
    }
    }
    }

    My question is, how can I put together a string, based on the values in input
    text boxes (which display the current quantity, which may or may not be changed
    by the user) in ActionScript, that a PHP script like the one above would
    understand? I'm using LoadVars for all my other PHP/Flash integration needs.
    It's screwing my head up trying to work out how to make each quantity variable
    reference the correct product, and do it the correct syntax for the query to
    work. My actionscript is currently looking something like this:

    ///////////////////LOAD VARS//////////////////////////
    cartOut = new LoadVars();
    cartIn = new LoadVars();
    updateOut = new LoadVars();
    updateIn = new LoadVars();
    iProductID_array = new Array();
    qty_array = new Array();
    sProductName_array = new Array();
    sStoreID_array = new Array();
    subTotal_array = new Array();
    function displayCart() {
    var n = cartIn.n;
    var i = 0;
    var y = 24;
    while (i<n) {
    newMc = _level0.content_mc.table_mc;
    newMc._y += y;
    newMc.itemreftext = sStoreID_array;
    newMc.itemnametext = sProductName_array;
    newMc.quantitytext = qty_array;
    newMc.pricetext = "?"+subTotal_array;
    i++;
    y += 23;
    newMc._visible = 1;
    table_mc.cartTotalBox._y = newMc._y+23;
    }
    }
    cartIn.onLoad = function(success) {
    var n = cartIn.n;
    var i = 0;
    if (n != 0) {
    while (i<n) {
    iProductID_array = cartIn;
    sStoreID_array = cartIn;
    sProductName_array = cartIn;
    qty_array = cartIn;
    subTotal_array = cartIn;
    duplicateMovieClip(table_mc.tableRow_mc, "tableRow"+i+"_mc", i);
    i++;
    }
    buttons_mc._visible = 1;
    displayCart();
    table_mc.cartTotal = "?"+cartIn.cartTotal;
    } else if (n == 0) {
    emptyCart_mc._visible = 1;
    buttons_mc._visible = 0;
    }
    };
    updateIn.onLoad = function(success) {
    var n = cartIn.n;
    var i = 0;
    if (n != 0) {
    while (i<n) {
    qty_array = updateIn;
    subTotal_array = updateIn;
    i++;
    }
    displayCart();
    table_mc.cartTotal = "?"+updateIn.cartTotal;
    } else {
    emptyCart_mc._visible = 1;
    buttons_mc._visible = 0;
    table_mc._visible = 0;
    }
    };
    cartOut.sendAndLoad("../view_cart.php", cartIn, "POST");
    ///////////////////////BUTTONS////////////////////////////////
    _level0.content_mc.buttons_mc.updatecartbtn_mc.onR elease = function() {
    updateMc = _level0.content_mc.table_mc;
    updateOut.num = 1;
    updateOut.prodID = iProductID_array;
    updateOut.qty = updateMc.quantitytext;
    updateOut.request = "update";
    updateOut.sendAndLoad("../view_cart.php", cartIn, "POST");
    };

    feed_me Guest

  2. Similar Questions and Discussions

    1. Flash player not working on some websites & have foundRegestry keys of older Flash players.
      Hi, like many people here I have problems seeing flash content on some websites but other websites work fine. I also found that YOUTUBE works...
    2. Flash player installed, but every site flash playerrequired for asks to install not working at all
      Hi all, wondering if someone would be kind enough to help me, PLEASE lol Flash player asks to be installed everytime I go onto any site that...
    3. XML Intergration, help needed!
      I am trying to intergrate the UPS Online Tools on my site. I am stuck and don't know what I can do. I keep getting this error message: Document...
    4. convert all flash site to both flash and no flash
      a friend has a site that is done with all flash. they asked me to help make it readable by more browsers. could some belly point me in the right...
    5. ASP.NET and Windows Office intergration
      has anyone ever intergrated Office products (word, excel, powerpoint, etc.) into an ASP.NET web application (run in ie). This is a major...
  3. #2

    Default Re: PHP/Flash Intergration

    Anyone? Go on... I'm sure someone has an idea...? I don't want a full solution, just an idea of PHP $_POST query syntax so I can work the rest out...
    feed_me Guest

  4. #3

    Default Re: PHP/Flash Intergration

    >>My question is, how can I put together a string, based on the values in
    >>input
    >>text boxes (which display the current quantity, which may or may not be
    >>changed
    >>by the user) in ActionScript, that a PHP script like the one above would
    >>understand? I'm using LoadVars for all my other PHP/Flash integration
    >>needs
    The example in Flash help will do the trick for learning this -
    [url]http://livedocs.macromedia.com/flash/8/main/00002336.html[/url]
    On the PHP side the variables in the send_lv will be in $_REQUEST ready for
    exploitation.

    --
    Lon Hosford
    [url]www.lonhosford.com[/url]
    May many happy bits flow your way!
    "feed_me" <webforumsuser@macromedia.com> wrote in message
    news:dvhukh$8hn$1@forums.macromedia.com...
    Hello, I've been struggling with this for ages now, so it's time I asked for
    help. I'm setting up a shopping cart in Flash, using PHP to process the
    information and store/retrieve from a MySQL database. I can add items to the
    cart and display them, no problem, however I can't work out how to update
    the
    quantities of items in the cart (other than adding more of that item from
    the
    item page). I can do it using just PHP, but I can't work out how I can get
    ActionScript to send the same string as a HTML form. I'm using a HTML form
    that
    looks like this as a template:

    echo " <tr>
    <td align=\"left\">{$row} {$row} {$row}</td>
    <td align=\"left\">{$row}</td>
    <td align=\"right\">\${$row}</td>
    <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty}]\"
    value=\"{$_SESSION]}\" /></td>
    <td align=\"right\">$" . number_format ($subtotal, 2) . "</td>
    </tr>\n";

    which returns the information submitted back to the same page, where the
    information would be updated based on what the user had entered, something
    like
    this:

    if (isset ($_POST)) {
    foreach ($_POST as $key => $value) {
    if ( ($value == 0) AND (is_numeric ($value)) ) {
    unset ($_SESSION);
    } elseif ( is_numeric ($value) AND ($value > 0) ) {
    $_SESSION = $value;
    }
    }
    }

    My question is, how can I put together a string, based on the values in
    input
    text boxes (which display the current quantity, which may or may not be
    changed
    by the user) in ActionScript, that a PHP script like the one above would
    understand? I'm using LoadVars for all my other PHP/Flash integration needs.
    It's screwing my head up trying to work out how to make each quantity
    variable
    reference the correct product, and do it the correct syntax for the query to
    work. My actionscript is currently looking something like this:

    ///////////////////LOAD VARS//////////////////////////
    cartOut = new LoadVars();
    cartIn = new LoadVars();
    updateOut = new LoadVars();
    updateIn = new LoadVars();
    iProductID_array = new Array();
    qty_array = new Array();
    sProductName_array = new Array();
    sStoreID_array = new Array();
    subTotal_array = new Array();
    function displayCart() {
    var n = cartIn.n;
    var i = 0;
    var y = 24;
    while (i<n) {
    newMc = _level0.content_mc.table_mc;
    newMc._y += y;
    newMc.itemreftext = sStoreID_array;
    newMc.itemnametext = sProductName_array;
    newMc.quantitytext = qty_array;
    newMc.pricetext = "?"+subTotal_array;
    i++;
    y += 23;
    newMc._visible = 1;
    table_mc.cartTotalBox._y = newMc._y+23;
    }
    }
    cartIn.onLoad = function(success) {
    var n = cartIn.n;
    var i = 0;
    if (n != 0) {
    while (i<n) {
    iProductID_array = cartIn;
    sStoreID_array = cartIn;
    sProductName_array = cartIn;
    qty_array = cartIn;
    subTotal_array = cartIn;
    duplicateMovieClip(table_mc.tableRow_mc, "tableRow"+i+"_mc", i);
    i++;
    }
    buttons_mc._visible = 1;
    displayCart();
    table_mc.cartTotal = "?"+cartIn.cartTotal;
    } else if (n == 0) {
    emptyCart_mc._visible = 1;
    buttons_mc._visible = 0;
    }
    };
    updateIn.onLoad = function(success) {
    var n = cartIn.n;
    var i = 0;
    if (n != 0) {
    while (i<n) {
    qty_array = updateIn;
    subTotal_array = updateIn;
    i++;
    }
    displayCart();
    table_mc.cartTotal = "?"+updateIn.cartTotal;
    } else {
    emptyCart_mc._visible = 1;
    buttons_mc._visible = 0;
    table_mc._visible = 0;
    }
    };
    cartOut.sendAndLoad("../view_cart.php", cartIn, "POST");
    ///////////////////////BUTTONS////////////////////////////////
    _level0.content_mc.buttons_mc.updatecartbtn_mc.onR elease = function() {
    updateMc = _level0.content_mc.table_mc;
    updateOut.num = 1;
    updateOut.prodID = iProductID_array;
    updateOut.qty = updateMc.quantitytext;
    updateOut.request = "update";
    updateOut.sendAndLoad("../view_cart.php", cartIn, "POST");
    };


    Motion Maker Guest

  5. #4

    Default Re: PHP/Flash Intergration

    Hey, Thanks for that, but I'm okay with that bit. My question really (I didn't
    ask it very well before), is with this bit:
    foreach ($_POST as $key => $value)
    I am not understanding how you have more than one $_POST? What is appended to
    each to identify it as different to the last? I know it comes from here:
    <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty}]\"
    value=\"{$_SESSION]}\" /></td>
    in the php/html form, so what I really want to know is the correct syntax to
    build the same query via actionscript. Do I need to make the UpdateOut.qty
    variable a more complex string, or is it the name of the variable (e.g.
    UpdateOut.qty for example)?

    feed_me Guest

  6. #5

    Default Re: PHP/Flash Intergration

    >>I am not understanding how you have more than one $_POST?

    That seems to be a PHP questions and there can be only one super global such
    as $_POST per script running. Flash can make as many requests to a server
    side script or scripts as you need. I could call the same script multiple
    times, with different variable values to direct the script to do different
    tasks. Regardless, for each request of a server script all the variables
    would be in $_REQUEST (I do not use $_POST so that one someone else would
    need to comment on).

    As for the $_SESSION variables, Flash cannot access those. The server side
    script would read and write those. Flash could have the $_SESSION variable
    key names either from a LoadVars converstation or user interaction with the
    Flash movie.

    >>Do I need to make the UpdateOut.qty variable a more complex string, or is
    >>it the name of the variable (e.g.
    UpdateOut.qty for example)?

    It appears to me you need to have the server script send the $_SESSION
    variable to the Flash movie and use it in a text field.

    --
    Lon Hosford
    [url]www.lonhosford.com[/url]
    May many happy bits flow your way!
    "feed_me" <webforumsuser@macromedia.com> wrote in message
    news:e08bff$3bc$1@forums.macromedia.com...
    Hey, Thanks for that, but I'm okay with that bit. My question really (I
    didn't
    ask it very well before), is with this bit:
    foreach ($_POST as $key => $value)
    I am not understanding how you have more than one $_POST? What is appended
    to
    each to identify it as different to the last? I know it comes from here:
    <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty}]\"
    value=\"{$_SESSION]}\" /></td>
    in the php/html form, so what I really want to know is the correct syntax
    to
    build the same query via actionscript. Do I need to make the UpdateOut.qty
    variable a more complex string, or is it the name of the variable (e.g.
    UpdateOut.qty for example)?


    Motion Maker Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139