4 Replies Latest reply on Jun 26, 2007 11:22 AM by kglad

    setProperty doesn't work with movieclip inside of movieclip

    BigdaddyVELTRI
      I originally had this set up this way and it worked.

      var hita:Boolean = false;
      logotop.onEnterFrame = function() {
      hita = this.hitTest(this._parent.middle.hitme);
      if (hita == true) {
      setProperty ("logotop", _alpha, "0");
      }
      }

      Then I put everything in a new movieclip with the instance name "printme".
      Now it doesn't work and doesn't give me an error.

      var hita:Boolean = false;
      printme.logotop.onEnterFrame = function() {
      hita = this.hitTest(this._parent.printme.middle.hitme);
      if (hita == true) {
      setProperty ("printme.logotop", _alpha, "0");
      }
      }

      Do you see anything wrong with the above code?
        • 1. Re: setProperty doesn't work with movieclip inside of movieclip
          kglad Adobe Community Professional & MVP
          remove the quotes around printme.logotop.
          • 2. Re: setProperty doesn't work with movieclip inside of movieclip
            Level 7
            BigdaddyVELTRI,

            > Then I put everything in a new movieclip with the instance name
            > "printme".

            Okay, if I'm following you right, the "point of view" now is inside
            printme, right?

            > Now it doesn't work and doesn't give me an error.
            >
            > var hita:Boolean = false;
            > printme.logotop.onEnterFrame = function() {

            So at this point, you're assigning a function to the
            MovieClip.onEnterFrame event of the logotop MovieClip instance (i.e., movie
            clip symbol) that exists inside printme.

            > hita = this.hitTest(this._parent.printme.middle.hitme);

            In this line, you're invoking MovieClip.hitTest() on the logotop
            instance and passing it the expression this._parent.printme.middle.hitme.
            Let's examine that a bit. In this context, the global "this" property
            refers to logotop, because that's how event handlers of this sort work in
            ActionScript 2.0. this._parent refers to the timeline or object that
            contains logotop; namely, printme. So this._parent.printme is possibly a
            problem. Does the printme movie clip contain within it another movie clip
            also instance named printme? If so, then this._parent.printme would indeed
            point to that inner printme (a sibling of logotop). If this isn't your
            aim -- if, say, middle is the sibling of logotop -- you may want to adjust
            the expression in that parameter.

            > if (hita == true) {
            > setProperty ("printme.logotop", _alpha, "0");

            The setProperty() function is actually pretty old. It was replace many
            versions ago with the (to my thinking) easier dot notation you're already
            using elsewhere in this script.

            The expression:
            setProperty ("printme.logotop", _alpha, "0");

            ... is the same as this:
            printme.logotop._alpha = 0;

            Much easier to read and deal with, right? In fact, that may even help
            you sort out your pathing issue.


            David Stiller
            Co-author, Foundation Flash CS3 for Designers
            http://tinyurl.com/2k29mj
            "Luck is the residue of good design."


            • 3. Re: setProperty doesn't work with movieclip inside of movieclip
              BigdaddyVELTRI Level 1
              Thank you both for your help!
              This worked:
              printme.logotop.onEnterFrame = function() {
              hita = this.hitTest(printme.middle.hitme);
              if (hita == true) {
              printme.logotop._alpha = 0;
              }