0 Replies Latest reply on Mar 20, 2009 2:43 PM by Newsgroup_User

    AS2 - Movie Clip Inside a Class

    Level 7
      Hi --

      I have a movie clip with a button and I am having trouble getting the button
      to be part of the class.

      The movie clip is named "clipContactMe" and I have "Export for Actionscript"
      selected. The identifier is "frmContactMe" and the Class is "ContactMe".

      I have a class file called ContactMe.as in the same directory with this
      code:

      class ContactMe extends MovieClip {

      public function ContactMe(){
      trace("contact me init");
      }

      private function btnSubmit_click() {
      trace("ccclick");
      }

      }

      When I initialize the class and put the movie on the stage I see the
      "contact me init" trace line.

      Now there is a "SUBMIT" in the "contact me" movie. The submit button is
      named "btnSubmit" in the library and "inst_btnSubmit" on the stage in the
      movie.

      From inside my class (shown above) I have tried a few ways to call the
      "btnSubmit_click" function but nothing works.

      If I add this line of code to the ContactMe() function:

      inst_btnSubmit.onRelease = function() { trace("click"); }

      I get this error: "There is no property with the name 'inst_btnSubmit'."

      However, if I add it this way:

      _root.contactme_mc.inst_btnSubmit.onRelease = function() {
      trace("click"); }

      it works ("contactme_mc" is the name of the ContactMe movie when I add it to
      the main movie)

      However, even with the above working if I try this:

      inst_btnSubmit.onRelease = function() { btnSubmit_click() }

      the btnSubmit_click() function does not get called.

      I'm pulling my hair out here!

      Thanks!

      Rich