3 Replies Latest reply on Feb 9, 2007 3:04 AM by Peter Lorent

    Class Method

    Marghoob Suleman Level 1
      Hello Guys,
      Hope you doing well...

      Please see the attached code....

      i've added onPress and onRelease event on a movieClip and when i was trying to use a movieClip (mainButton, circleButton) of this class it show undefined. i've tried with Delegate.create. but not success... :(

      please help me.
        • 1. Re: Class Method
          Peter Lorent Level 2
          Well, there we go again... (this extending the MovieClip Class is a very persistent issue).
          You are extending the MovieClip Class. That means there should be a relationship between the class and a movieclip in the library (using the linkage identifier). You instantiate an instance either by putting an instance of the movieclip on the stage or by attaching an instance using MovieClip.attachMovie().
          You on the other hand are creating an empty movieclip, passing it to the class as a target. Essentialy you are using composition instead of inheritance. I've attached corrected code.
          Now, this method in your class:
          private function onReleaseEvent() {
          var newM:Music = new Music()
          You create a new instance of Music 'newM' with its own properties and methods (you create a NEW object) but you don't pass it a target mc.... so the trace comes up with undefined. You need to use the current instance here.

          • 2. Re: Class Method
            Marghoob Suleman Level 1

            Thank you very much Mr. LuigiL...
            It was awesome help... I was using extends like as standard... but now i know why should use this... and it works perfectly...

            Thanks again... after all senior is always senior... :D

            • 3. Re: Class Method
              Peter Lorent Level 2
              >> was using extends like as standard
              You're not the only one...