3 Replies Latest reply on Oct 11, 2006 10:01 AM by Newsgroup_User

    import Class object

    Level 7
      I have a class that I need to validate a form. My problem right now is
      that I am pretty sure the class is not getting imported, but I don't
      understand why?

      I am doing the following.
      On the first frame I have:

      import mainObj;

      The class starts like this, so it should trace if imported correctly, right?

      //main class objeect for Figge website
      class mainObj {
      //properties
      //
      private var $currentPage:String;
      private var $pageToLoad:String;
      private var $fadeOutInterval, $fadeInInterval:Number;
      private var $sliderMoving:Boolean;
      private var $sliderInterval:Number;
      private var $sliderDest:Number;
      private var $pctComplete:Number;
      private var $pageTrans:Boolean;
      //methods
      //
      public function mainObj() {
      trace("mainObj INIT called!!!");
      this.$init.apply(this, arguments);
      }
      .
      .
      .


      What could be wrong?

      Thanks for any help!
      Brian
        • 1. Re: import Class object
          AnandMX Level 1
          dont import the same class inside the same class as it raises error. in place of this you can create a class reference object for referring methods in current class.
          //import mainObj;
          //main class objeect for Figge website
          class mainObj {
          //properties
          //
          private var $currentPage:String;
          private var $pageToLoad:String;
          private var $fadeOutInterval, $fadeInInterval:Number;
          private var $sliderMoving:Boolean;
          private var $sliderInterval:Number;
          private var $sliderDest:Number;
          private var $pctComplete:Number;
          private var $pageTrans:Boolean;
          private static var $clsRef:mainObj;//Class reference
          //methods
          //
          public function mainObj() {
          trace("mainObj INIT called!!!");
          clsRef=this;//now u can refer any methods using clsRef
          //this.$init.apply(this, arguments);
          }
          }
          • 2. Re: import Class object
            Peter Lorent Level 2
            The import statement doesn't import anything. It merely enables you not to type the fully qualified path to the class for instance when you use packages. You need to instantiate a new instance of the class and in your case - where you have your class in the same folder as your fla - you don't need the import statement.
            var test:mainObj=new mainObj();
            • 3. Re: import Class object
              Level 7
              LuigiL, thank you. I did that and that seems to work. What I still
              having issues with is calling a function in that class.

              I did what you said with the:
              var test:mainObj=new mainObj();

              I now want to call a function inside mainObj called validateForm and
              that seems to not work. Here is what I was trying:

              on (release, releaseOutside, dragOut) {
              _root.$main.validateForm(_parent.tf_name.text,
              _parent.tf_company.text,...);
              }

              That function also has a trace in it and that never gets triggered. What
              could be wrong with what I am doing?

              Thank you for your help!
              Brian