Learn Actionscript - AHFX

Advanced Actionscript 

ahfx actionscript learning actionscript

AHFX Actionscript Home
Basic Actionscript
Intermediate Actionscript
Advanced Actionscript
About AHFX
Contact AHFX
Great Actionscript Links

Actionscript 2.0 Flash Implementation

If everything went well you will get a display of a heading row, two items, and grand total row. Now you can change the quantity textbox to a input box and make your update_btn active. After a little tweaking it looks like this:

Now if you change the quantity and hit update, you will get a new total for that item and a new grand total. You can also create "Add to Cart" buttons to add items into the cart. New output looks like this:

If you want to be able to remove an item from the cart you will need to change the Shopping Cart Actionscript 2.0 Class to look like this:

import com.ahfx.Product;
class com.ahfx.Shopping {
   private var cart:Array;
   private var elementCount:Number;
   function Shopping(){
      cart = new Array(20);
      elementCount = 0;
   function addElement(object){
      cart[elementCount++] = object;
   function getTotal():Number{
      var total = 0;
      var i;
         var tempProduct:Product = cart[i];
         total += tempProduct.getTotal();
      return total;
   function size():Number{
      return elementCount;
   function getElement(index){
      return cart[index];
   function removeElementAt(index) {
      if (index <= elementCount && index > -1){
         delete cart[index];
         for (var i = index+1; i<elementCount; i++) {
            cart[i-1] = cart[i];

Our new output is more attractive and it has reduced the file size to 1KB.

Continue to page 5

If this tutorial helped you, show your support and send me something from my wish list.
Click on an item below and then choose
Adam Hayes (Gift Registry Address) for the Ship to Address.
It is that easy!


Featured Tutorials

Flash Shopping Cart Tutorial
Create a custom Flash Shopping Cart that will add, update, and show products.

Flash MX 2004 Custom Actions
Take your custom classes to the next level and have Flash treat them as built in classes.

Pass Variables to Flash
Quick and dirty way of passing variables to your flash animations.

Affordable Web Design and Hosting
Find out how you can cut your overhead by hosting with AHFX.net

Affordable Custom Art
Get your pictures custom framed. Amazing Prices. Outstanding Quality.

AH Digital FX Studios
Disclaimer | Site Map | Idaho Web Design