Learn Actionscript - AHFX

Intermediate Actionscript - Strong Typing and Custom Extentions 

ahfx actionscript learning actionscript

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

Flash MX 2004 CustomActions

Now that we have our methods defined, lets support the strong typing option the is available in Flash MX 2004 for actionscript 2.0. For this we add another folder. Here is the code:

<?xml VERSION="1.0"?>
<customactions>
   <actionspanel>
   <folder VERSION="6" id="com.ahfx" index="true" name="com.ahfx" tiptext="Contains info for com.ahfx package">
      <folder VERSION="6" id="[com.ahfx.ShoppingCart]" name="ShoppingCart" tiptext="ShoppingCart">
         <folder VERSION="6" id="Methods" name="Methods" tiptext="Shopping Cart methods">
         <string
            object="[com.ahfx.ShoppingCart]"
            text=".addElement(% object %)"
            type="procedure"
            version="6"
            name="getTotal"
            tiptext="Number: returns the total of the price of the Products in the Shopping Cart" />
         </folder>
      </folder>
      <folder name="Types" id="Types" index="true" tiptext="Types that can be used for strong typing">
      <string
         name="ShoppingCart"
         tiptext="ShoppingCart type"
         text="ShoppingCart" />
      </folder>
   </actionspanel>
</customactions>

 

The key to this folder is having the name be Types, id be Types and index be true. By adding this code you add your custom classes to the dropdown for the class types.


Custom Class Extentions

You´ll notice that we've used my_sc as the shopping cart name. We can get the method dropdown list to appear for anything with our extention (in this case _sc for shoppingcart). This is done by adding the following code to our file:

<?xml VERSION="1.0"?>
<customactions>
   <actionspanel>
   <folder VERSION="6" id="com.ahfx" index="true" name="com.ahfx" tiptext="Contains info for com.ahfx package">
      <folder VERSION="6" id="[com.ahfx.ShoppingCart]" name="ShoppingCart" tiptext="ShoppingCart">
         <folder VERSION="6" id="Methods" name="Methods" tiptext="Shopping Cart methods">
         <string
            object="[com.ahfx.ShoppingCart]"
            text=".addElement(% object %)"
            type="procedure"
            version="6"
            name="getTotal"
            tiptext="Number: returns the total of the price of the Products in the Shopping Cart" />
         </folder>
      </folder>
      <folder name="Types" id="Types" index="true" tiptext="Types that can be used for strong typing">
      <string
         name="ShoppingCart"
         tiptext="ShoppingCart type"
         text="ShoppingCart" />
      </folder>
   </actionspanel>
   <codehints>
      <typeinfo object="com.ahfx.ShoppingCart" pattern="*_sc" />
      <typeinfo object="com.ahfx.ShoppingCart" pattern="ShoppingCart" />
      <typeinfo object="com.ahfx.ShoppingCart" pattern="com.ahfx.ShoppingCart" />
   </codehints>
</customactions>

 

Please notice that there are no square brackets around com.ahfx.ShoppingCart this time. That little nuance caused me a lot of grief while trying to get everything to work.

Continue to page 4


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!
 

 

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