Learn Actionscript - AHFX

Intermediate Actionscript - Flash Shopping Cart 

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

Now let's say that we want to modify the quantity of an item in our Shopping cart. We will use the getElement method for this.

import com.ahfx.Product;
import com.ahfx.Shopping;
var myProduct = new Product();
myProduct.setDesc("Teddy Bear");

var myOtherProduct = new Product();
myOtherProduct.setDesc("Cool Sunglasses");

var shop_cart = new Shopping();

var tempProduct:Product = shop_cart.getElement(1);


Our customer has decided to buy another pair of sunglasses (because they are so cool). We use the getElement() method to return the sunglasses. Notice that this is a zero based Shopping Cart. The first item is 0, the second is 1, etc. After we get the Product out of the cart, we can modify its quanity to 2. This outputs the following:


We can see that the total cost of all the items in the Shopping cart has increased to 34.95.

This ends the intermediate Actionscript 2.0 lesson. Although this has been a simple walkthrough, this is a solid base that we wish to build upon. The Shopping cart still needs a remove method for taking things out of the cart and other enhancing methods. If you continue to the advanced page, you will learn how to take the shopping cart you have created and display it in a DataGrid object.
Continue to advanced page.
We would love to hear your feedback. Please email us as info AT ahfx DOT com.

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