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:
var myProduct = new Product();
var myOtherProduct = new Product();
var shop_cart = new Shopping();
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:
SUPPORT THIS SITE 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!