Ask a Question related to Macromedia Flash Data Integration, Design and Development.
-
feed_me #1
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
-
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... -
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... -
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... -
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... -
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... -
feed_me #2
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
-
Motion Maker #3
Re: PHP/Flash Intergration
>>My question is, how can I put together a string, based on the values in
The example in Flash help will do the trick for learning this ->>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
[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
-
feed_me #4
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
-
Motion Maker #5
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.
UpdateOut.qty for example)?>>Do I need to make the UpdateOut.qty variable a more complex string, or is
>>it the name of the variable (e.g.
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



Reply With Quote

