2 Replies Latest reply on Nov 28, 2015 6:42 AM by kglad

    Zoom in Zoom Out Limit AS2

    mandar vedak Level 1

      Hello,

       

      I am using this code for zoom in zoom out image,

       

      i looking for restrict the zoom in as well as zoom out function to stop

       

      on (press)

      {

          _root.diesel.engine2._xscale = _root.diesel.engine2._xscale + 5;

          _root.diesel.engine2._yscale = _root.diesel.engine2._yscale + 5;

      }

       

      on (press)

      {

          _root.diesel.engine2._xscale = _root.diesel.engine2._xscale - 5;

          _root.diesel.engine2._yscale = _root.diesel.engine2._yscale - 5;

      }

        • 1. Re: Zoom in Zoom Out Limit AS2
          nezarov Level 4

          on (press)

          {

              _root.diesel.engine2._xscale = _root.diesel.engine2._xscale - 5;

              _root.diesel.engine2._yscale = _root.diesel.engine2._yscale - 5;

          if (_root.diesel.engine2._xscale < 100)

          {

          _root.diesel.engine2._xscale = 100

          _root.diesel.engine2._yscale = 100

          }

          }

          • 2. Re: Zoom in Zoom Out Limit AS2
            kglad Adobe Community Professional & MVP

            you should not apply code to objects.  assign each an instance name (in the properties) and use that name in your code.

             

            eg, if the zoom buttons/mcs have instance names zoomUp_mc, and zoomDown_mc:

             

            var maxZoom:Number=400;

            var minZoom:Number = 10;

             

            zoomUp_mc.onPress=function(){

                _root.diesel.engine2._xscale = _root.diesel.engine2._xscale + 5;

                _root.diesel.engine2._yscale = _root.diesel.engine2._yscale + 5;

            if(_root.diesel.engine2._xscale>maxZoom){

              _root.diesel.engine2._xscale = _root.diesel.engine2._yscale = maxZoom;  

            }

            }

             

            zoomDown_mc.onPress=function(){

                _root.diesel.engine2._xscale = _root.diesel.engine2._xscale - 5;

                _root.diesel.engine2._yscale = _root.diesel.engine2._yscale - 5;

            if(_root.diesel.engine2._xscale<minZoom){

              _root.diesel.engine2._xscale = _root.diesel.engine2._yscale = minZoom;  

            }

            }