Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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
}
}
Copy link to clipboard
Copied
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;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now