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

How can we use as3 to stretch images?

New Here ,
Apr 14, 2020 Apr 14, 2020

Looking for a way to code, "When Dragged On Image, Push, Pull, Stretch pixels.
I want to be able to distort images I publish by Click & Dragging and via Mouse Wheel. Would be ideal if: Drag to stretch, and mouse wheel to scale images.

Signed: Clueless

263
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
Contributor ,
Apr 14, 2020 Apr 14, 2020
LATEST

Hi Tom,

I'm not sure if this would do it for you, and I don't know how to use the mouse wheel as a programmatic input device -- never done that before.

But, I'd make the image as a MovieClip (MC): call it mainImage.  I'd make another graphic object as MC that acts a "dragging handle,": call it draggingHandle.

I'd put draggingHandle on top of the edge of mainImage.

This code should work:

var mainImageOrigWidth = mainImage.width;

draggingHandle.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
draggingHandle.addEventListener(MouseEvent.MOUSE_UP,stopDragging);

function startDragging(e:MouseEvent):void{
	draggingHandle.startDrag();
}

function stopDragging(e:MouseEvent):void{
	mainImage.scaleX = (draggingHandle.x - mainImage.x) / mainImage.width;
	draggingHandle.stopDrag();
}

draggingHandle.jpg

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