0 Replies Latest reply on Sep 2, 2008 8:27 AM by BudHud

    File and Class Communication

    BudHud
      It seems the program file and class file are not talking. I get this message inside program file: # 1120: Access denied; undefined property: myProduct. It applies to these statements:

      myProduct.setQuantity(3);
      myProduct.setPrice(2.99);
      myProduct.setDesc("Teddy Bear");

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

      Then in the class file I get the non-error message # 1084 class ‘Product’ will the scoped to the default namespace: internal; it will not be visible outside of this package. .

      I’m that close if you could help.

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

      <mx:Script>
      <![CDATA[

      import Product;
      private 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>


      package
      {
      public class Product {

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

      public function Product() {

      }


      public function getPrice():Number {
      return price;
      }

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

      public function getQuantity():Number {
      return quantity;
      }

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

      public function getDesc():String {
      return desc;
      }

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

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

      }
      }

      Thanks,

      BudHud