3 Replies Latest reply on May 3, 2006 1:40 PM by Peter Lorent

    Problem reaching variables and functions within a class

    Level 7

      Hi there,


      I'm having problems when trying to reach variables and functions within a
      class. I'm new at classes!!!
      Once I declared a function through the mc events all vars and functions get
      undefined.

      To be honest it's quit difficult for me to explained my problem. So I
      created a small example:

      Basically I would like to acess $mc or traceFunction from a rollOver mc
      event.


      you can download files here: www.peter-monte.com/class.zip

      // /////////////////////////////////////////////////////////////
      myClass.as:

      class myClass {

      var $mc:MovieClip;

      function myClass ( _mc:MovieClip ) {
      $mc = _mc;
      applyEventsTo ($mc);
      }

      private function applyEventsTo ( _mc:MovieClip ) {
      trace ( _mc ); // Outputs _level0.myMc
      _mc.onRollOver = RollOver;
      }

      private function RollOver ( _mc:MovieClip ) {
      trace ( $mc ); // Outputs undefined
      trace ( traceFunction) // Outputs undefined
      }

      private function traceFunction () {
      trace ( $mc ); // Outputs undefined
      }

      }
      // /////////////////////////////////////////////////////////////
      myClass.fla:

      this.stop ();
      var mcClass:myClass = new myClass (myMc);
      trace (mcClass.$mc); // Outputs _level0.myMc
      // /////////////////////////////////////////////////////////////

      Can anyone help me, please?

      Thanks in advanced.