Learn Mootools - AHFX

Intermediate Actionscript - Flash Shopping Cart 

ahfx Mootools learning Mootools

AHFX Mootools Home
Basic Mootools
Contact AHFX
 
 
 
 

Actionscript 2.0 Flash Implementation

Now we are going to take our new Actionscript 2.0 class and use it in a Flash application. Make sure that you have saved the final version of your actionscript and close down Flash. Open it back up and this time start a new Flash Application. Create a keyframe and enter the following code:

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

var myOtherProduct = new Product();
myOtherProduct.setQuantity(1);
myOtherProduct.setPrice(12.99);
myOtherProduct.setDesc("Cool Sunglasses");

var shop_cart = new Shopping();
shop_cart.addElement(myProduct);
shop_cart.addElement(myOtherProduct);
trace(shop_cart.getTotal());

 

First we import our two classes Product and Shopping. This could also have been accomplished by import com.ahfx.*; It would just import all of the classes in that package. We create the same two Products that we created in the Basic Tutorial. We create a Shopping cart to hold the products and add the products to the cart using addElement(). Finally we trace to find the total of all the Products in the Cart. The output is as follows:

21.96

Continue to page 4


If this FREE tutorial helped you at all, please consider clicking on a link to help support this site.
---OR---
Donate to the cause by sending us an Amazon Gift Certificate.
Click Here to Send an Amazon Gift Certificate to info@ahfx.com

 


 

Creative suite generic 125x125

Featured Tutorials


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