1 Reply Latest reply on Nov 19, 2006 7:26 AM by kglad

    MovieClips and external code

    noviceone
      I have a movieClip in my library called mcButton with code attached like so:

      this.onRelease = function():Void
      {
      trace("Released: "+ this);
      this.button_txt.setTextFormat(mouseActive_fmt);
      }

      Now I want to use several instances of these buttons on my stage. But I can;t get the clip to react to any event from an external #include file with code like onRelease - only the code that is on the symbol works. I did it this way so I wouldn't have to write the same behavoirs for every button I placed on the stage. Here is my Include code:
      btnContactUs_mc.onRelease = function():Void
      {
      trace("timeline release code has run")
      _root.attachMovie("mcContactUs","contactUs_mc",10); //sub navbar
      }
      I get nothing from this at all. Does the movieClip code take precedence? If I put everything in the #include file it works fine. (of couse I change "this" to "btnContactus" when I move it).
      I know I could have extented the movieclip class instead but I chose to do it this way. It should work, right?
        • 1. Re: MovieClips and external code
          kglad Adobe Community Professional & MVP
          you can have an on(release) handler and a this.onRelease or btnContactUs_mc.onRelease and both will execute (whether the timeline code is in an .as file or not is irrelevent).

          but you can have, at most, one on(release) attached to your button that will execute. (always the last defined will execute because it over-writes the first).

          and you can have, at most, one this.onRelease/btnContactUs_mc.onRelease (where this references btnContactUs_mc) that will execute. and again, the last defined will execute because it over-writes the first.

          code attached to a movieclip's timeline (first frame) executes after code that's on the timeline/frame that instantiates the movieclip. so, your this.onRelease will over-write your btnContactUs_mc.onRelease.