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

Zoom fluent problem

New Here ,
Aug 03, 2015 Aug 03, 2015

Copy link to clipboard

Copied

Hello! I've got a problem with the fluency of the zoom. When I want to zoom the image is bouncing. Please help me!

import flash.events.MouseEvent;

stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);

function Zoom(e:MouseEvent):void

{      

  var mod:Number = 20;

  img_mc.scaleX += e.delta / mod;

     img_mc.scaleY += e.delta / mod;

  if( img_mc.scaleX<1){

  img_mc.scaleX= img_mc.scaleY=1;

  }

     img_mc.x = ((mouseX) - (((e.stageX - 683) *  img_mc.scaleX)));

   img_mc.y = ((mouseY) - (((e.stageY - 280.5) *  img_mc.scaleY)));

}

Thanks

TOPICS
ActionScript

Views

329

Translate

Translate

Report

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 ,
Aug 03, 2015 Aug 03, 2015

Copy link to clipboard

Copied

I would suggest two things - first, if this is an image you're zooming, that smoothing is enabled in it's properties or you're setting it by code. Second, you have 280.5 in your y setting. Things cannot be on half pixels even though Flash, as a vector tool, allows it.Flash shouldn't allow it. Not using whole integers for positioning can make text look ugly, images appear aliased, etc...

Votes

Translate

Translate

Report

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
New Here ,
Aug 03, 2015 Aug 03, 2015

Copy link to clipboard

Copied

Where can i enabled the smoothing? What can i use instead of these numbers?

Thanks

Votes

Translate

Translate

Report

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 ,
Aug 03, 2015 Aug 03, 2015

Copy link to clipboard

Copied

You enable smoothing either in the images properties, or by code if you're loading by code. Use integers instead of floats is all...

Votes

Translate

Translate

Report

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
New Here ,
Aug 03, 2015 Aug 03, 2015

Copy link to clipboard

Copied

LATEST

Other question: If i use this zoom code, but i want to zoom to the position of the mouse?

function Zoom(e:MouseEvent):void

{      

  var mod:Number = 20;

  kep2.scaleX += e.delta / mod;

    kep2.scaleY += e.delta / mod;

  if(kep2.scaleX<1){

kep2.scaleX=kep2.scaleY=1;

}

    kep2.scaleX *= Math.max(scaleY,scaleX);

    kep2.scaleY *= Math.max(scaleX,scaleY);

thanks

Votes

Translate

Translate

Report

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