Skip to main content
Known Participant
November 28, 2015
Question

Zoom in Zoom Out Limit AS2

  • November 28, 2015
  • 2 replies
  • 1310 views

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;

}

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
November 28, 2015

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;  

}

}

Inspiring
November 28, 2015

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

}

}