Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Zoom in Zoom Out Limit AS2

Explorer ,
Nov 27, 2015 Nov 27, 2015

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;

}

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 28, 2015 Nov 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

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2015 Nov 28, 2015
LATEST

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;  

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines