3 Replies Latest reply on Oct 15, 2006 4:35 PM by kglad

    Controlling a MC with another MC

    pindus
      Hi,

      I've created a rectangle and converted it into a MC. I named the MC 'map'.

      I have then created 6 small mc:s (right, left, up, down, zoomOut, zoomIn)

      I've added the following code to each of the small MC:s. Modified for each of the functions. The problem is, if I add the code to two mc:s it's no longer working. And how do I get the big MC to move continiously while holding the mousebutton down? Right now I have to click everytme I want to move it.

      Does anyone know how to fix, or maybe a page where I can read more?

      Thanx for any help. I'm stuck, and can't find anything about this on the net. Although it's probably very simple.

        • 1. Re: Controlling a MC with another MC
          kglad Adobe Community Professional & MVP
          mouseDown methods execute whenever the left mouse button is pressed no matter where the mouse pointer is located (assuming flash has focus).

          you want to use an on(press) handler and initiate a loop that continues to execute until an on(release,releaseOutside) is detected, at which point you'll want to terminate your loop.
          • 2. Re: Controlling a MC with another MC
            pindus Level 1
            I tried now with a loop. But it moves too fast. I tried to set the increase to 0.01, but then nothing happens.

            on (press){
            for (i=0; i<500;i++){
            this._parent.map._y = this._parent.map._y + 0.1;
            }
            }

            I also tried with the release handler, but it's not allowed. =(

            on (press){
            for (i=0; i<500;i++){
            this._parent.map._y = this._parent.map._y + 0.01;
            this.onRelease() = function {
            break;
            }
            }
            }

            I'm a newbee to all this and I understand it's basic, but I just can't work it out..
            • 3. Re: Controlling a MC with another MC
              kglad Adobe Community Professional & MVP
              for-loops and while-loops execute from beginning to end before anything is updated on-stage and so are not appropriate for animation. use an onEnterFrame(), setInterval() or frame loop.