6 Replies Latest reply on Nov 18, 2011 12:31 PM by LukeElChul

    Cant figure this out!

    LukeElChul Level 1

      im making a game kind of like a RTS and ive made a cam what zooms in to show a part of the stage all this works fine i also have 3 buttons what attach stuff to the stage is there any way to get them 3 buttons inside the cam so the buttons are like on your screen and are always there even if you move the cam while your playing the game (buttons are on scene 1 layer 1 and when the cam is moved buttons just stay in the same place).

       

      This is my cam script.

       

      cam is a black square movie clip named cam.

       

      Inside it on layer 1 there is this script.

       

       

      ......................................................................................

       

      parentColor.setTransform(camColor.getTransform()); function camControl() { parentColor.setTransform(camColor.getTransform()); var scaleX = sX/this._width; var scaleY = sY/this._height; _parent._x = cX-(this._x*scaleX); _parent._y = cY-(this._y*scaleY); _parent._xscale = 100*scaleX; _parent._yscale = 100*scaleY; } function resetStage() { var resetTrans = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0}; parentColor.setTransform(resetTrans); _parent._xscale = 100; _parent._yscale = 100; _parent._x = 0; _parent._y = 0; } // make frame invisible this._visible = false; // Capture stage parameters var oldMode = Stage.scaleMode; Stage.scaleMode = "exactFit"; var cX = Stage.width/2; var cY = Stage.height/2; var sX = Stage.width; var sY = Stage.height; Stage.scaleMode = oldMode; // create color instances for color // transforms (if any). var camColor = new Color(this); var parentColor = new Color(_parent); // Make the stage move so that the // v-cam is centered on the // viewport every frame this.onEnterFrame = camControl; // Make an explicit call to the camControl // function to make sure it also runs on the // first frame. camControl(); // If the v-cam is ever removed (unloaded) // the stage, return the stage to the default // settings. this.onUnload = resetStage;

        • 1. Re: Cant figure this out!
          kglad Adobe Community Professional & MVP

          your code's not legible.

          • 2. Re: Cant figure this out!
            LukeElChul Level 1

            what do you meen by legible? is it because i havent spaced it out right and its not readable?

            • 3. Re: Cant figure this out!
              kglad Adobe Community Professional & MVP

              correct.

               

              copy your code and paste it (ctrl-v or maccrapkey-v) into a message.

              1 person found this helpful
              • 4. Re: Cant figure this out!
                LukeElChul Level 1

                There thanks for your patience.

                 

                parentColor.setTransform(camColor.getTransform());

                function camControl() {

                parentColor.setTransform(camColor.getTransform());

                var scaleX = sX/this._width;

                var scaleY = sY/this._height;

                _parent._x = cX-(this._x*scaleX);

                _parent._y = cY-(this._y*scaleY);

                _parent._xscale = 100*scaleX;

                _parent._yscale = 100*scaleY;

                }

                function resetStage() {

                var resetTrans = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};

                parentColor.setTransform(resetTrans);

                _parent._xscale = 100;

                _parent._yscale = 100;

                _parent._x = 0;

                _parent._y = 0;

                }

                // make frame invisible

                this._visible = false;

                // Capture stage parameters

                var oldMode = Stage.scaleMode;

                Stage.scaleMode = "exactFit";

                var cX = Stage.width/2;

                var cY = Stage.height/2;

                var sX = Stage.width;

                var sY = Stage.height;

                Stage.scaleMode = oldMode;

                // create color instances for color

                // transforms (if any).

                var camColor = new Color(this);

                var parentColor = new Color(_parent);

                // Make the stage move so that the

                // v-cam is centered on the

                // viewport every frame

                this.onEnterFrame = camControl;

                // Make an explicit call to the camControl

                // function to make sure it also runs on the

                // first frame.

                camControl();

                // If the v-cam is ever removed (unloaded)

                // the stage, return the stage to the default

                // settings.

                this.onUnload = resetStage;

                • 5. Re: Cant figure this out!
                  kglad Adobe Community Professional & MVP

                  if your buttons are attached to the same timeline as your camera, you can use:

                   

                  parentColor.setTransform(camColor.getTransform());

                  function camControl() {

                  topLeftF();

                  .

                  .

                  }

                   

                  function topLeftF():Void{

                  btn1._x=this._x-this._width/2;

                  btn1._y=this._y-this._height/2;

                   

                  .

                  .

                  }

                  1 person found this helpful
                  • 6. Re: Cant figure this out!
                    LukeElChul Level 1

                    ive figered it out all i done was make a new box make it a movie clip and inserted the same code and the btn's where visable. Thanks anyway (: