1 Reply Latest reply on Apr 15, 2009 3:13 PM by kglad

    Need help with a script...please :)

    caroline smells Level 1

      After searching the internet on advice for new programers starting with AS3.0 ive soon realised toI have to AS2.0 to learn the fundamentals first

      so Ive been going through a tutorial which actualy makes a lot of sence, but the result doesnt...

       

      heres the as file script...

       

      class com.ahfx.Product {

      private var price:Number;
      private var desc:String;
      private var quantity:Number;


      function Product () {
      }

      function getPrice ():Number{
      return price;

      }
      function setPrice (price:Number):void {
      this.price = price ;
      }
      function getQuantity (quantity:Number) :void {
      return quantity;
      }

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

      }

      function getDesc (desc:String) {
      return desc;

      }
      function setDesc (desc:String) :void {
      this.desc = desc;
          
      }
      function getTotal (total:Number) {
      return price*quantity
      }
      }

       

       

      and then I created a new Flash File with the following script on the timeline...

       

      import com.ahfx.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());

       

      to me this makes sence and I wouldve thought Id get some kind of output but all I get is

       

      undefined

      undefined

      undefined

      undefined

       

      Any ideas why

       

      thanks in advance!

       

      Adam