topical media & game development

talk show tell print

actionscript-misc-Items.ax

actionscript-misc-Items.ax [swf] flex


  package {
    // A simple data-storage class containing the Item objects for the game.
    public class @ax-actionscript-misc-Items {
      // The fruits
      fruit var orange:actionscript_misc_Item = new actionscript_misc_Item("Orange", "actionscript-misc-assets-fruit-orange.jpg", 1);
      fruit var apple:actionscript_misc_Item  = new actionscript_misc_Item("Apple", "actionscript-misc-assets-fruit-apple.jpg", 2);
      
      // The colors
      color var orange:actionscript_misc_Item = new actionscript_misc_Item("Orange", "actionscript-misc-assets-color-orange.jpg", 3);
      color var purple:Item = new actionscript_misc_Item("Purple", "actionscript-misc-assets-color-purple.jpg", 4);
  
      // Arrays that store complete sets of items (i.e., all the fruits, or
      // all the colors)
      fruit var itemSet:Array = [fruit::orange, fruit::apple];
      color var itemSet:Array = [color::orange, color::purple];
  
      // An array of namespaces representing the types of the item 
      // sets in the game
      private var itemTypes:Array = [color, fruit];
      
      // Returns all the fruit items in the game
      fruit function get@ax-actionscript-misc-Items ():Array {
        return fruit::itemSet.slice(0);
      }
  
      // Returns all the color items in the game
      color function get@ax-actionscript-misc-Items ():Array {
        return color::itemSet.slice(0);
      }
      
      // Returns the list of available item types in the game
      public function getItemTypes ():Array {
        return itemTypes.slice(0);
      }
    }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.