Skip to main content
Participating Frequently
August 25, 2017
Answered

Zoom In/Out Button

  • August 25, 2017
  • 2 replies
  • 3798 views

I am an inexperienced Flash/Animate user trying to figure out how to create  buttons where a user can zoom in and out. It would be just like a zoom in button and zoom out button on google maps. If anyone knows how to make this happen please help, I would greatly appreciate any insight. A panning function would also be preferable, also like on google maps.

Thank you!

This topic has been closed for replies.
Correct answer kglad

var mc_to_zoom:MovieClip = this;  // <-or whatever movieclip you want to zoom

zoom_in.addEventListener(MouseEvent.CLICK,zoomF);

zoom_out.addEventListener(MouseEvent.CLICK,zoomF);

function zoomF(e:MouseEvent):void{

if(e.currentTarget.name.indexOf('in')>-1){

mc_to_zoom.scaleX+=.3;  // or whatever zoom factor

mc_to_zoom.scaleY+=.3;

} else {

mc_to_zoom.scaleX-=.3;

mc_to_zoom.scaleY-=.3;

}

}

2 replies

Inspiring
August 26, 2017

Are you using Actionscript 3.0 or HTML5 Canvas?

Participating Frequently
August 28, 2017

ActionScrip 3.0

kglad
Community Expert
Community Expert
August 25, 2017

you can use the scaleX and scaleY properties of you main timeline/movieclip (if you're using actionscript).

Participating Frequently
August 28, 2017

Thank you for that insight. Do you know the coding language I would use for this?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 28, 2017

var mc_to_zoom:MovieClip = this;  // <-or whatever movieclip you want to zoom

zoom_in.addEventListener(MouseEvent.CLICK,zoomF);

zoom_out.addEventListener(MouseEvent.CLICK,zoomF);

function zoomF(e:MouseEvent):void{

if(e.currentTarget.name.indexOf('in')>-1){

mc_to_zoom.scaleX+=.3;  // or whatever zoom factor

mc_to_zoom.scaleY+=.3;

} else {

mc_to_zoom.scaleX-=.3;

mc_to_zoom.scaleY-=.3;

}

}