1 Reply Latest reply on Sep 1, 2008 7:54 PM by VarioPegged

    Class File Problem

    BudHud Level 1
      Can you tell me why I am getting an error message in my Product class file. I get error #1046: Type was not found or was not a complile-time constant: void with all of the set functions:

      function setPrice(myVar:Number):Void {
      function setQuantity(quantity:Number):Void {
      function setDesc(myVar:String):Void {

      The class is listed in the file folder: Nprod/Product.as.


      This is my file, Nprod.mxml.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>
      <![CDATA[

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

      trace(myProduct.getDesc());
      trace(myProduct.getPrice());
      trace(myProduct.getQuantity());
      trace(myProduct.getTotal());

      ]]>
      </mx:Script>
      </mx:Application>

      This is my actionscript class, Product.as.

      package
      {
      class Product {

      //Instance Variables
      private var price:Number;
      private var desc:String;
      private var quantity:Number;

      function Product() {
      }

      function getPrice():Number {
      return price;
      }

      function setPrice(myVar:Number):Void {
      price = myVar;
      }

      function getQuantity():Number {
      return quantity;
      }

      function setQuantity(quantity:Number):Void {
      this.quantity = quantity;
      }

      function getDesc():String {
      return desc;
      }

      function setDesc(myVar:String):Void {
      desc = myVar;
      }

      function getTotal():Number {
      return price*quantity;
      }

      }
      }

      Thanks,

      BudHud