Highlighted

How can we use as3 to stretch images?

New Here ,
Apr 14, 2020

Copy link to clipboard

Copied

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

Views

67

Likes

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

How can we use as3 to stretch images?

New Here ,
Apr 14, 2020

Copy link to clipboard

Copied

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

Views

68

Likes

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
Apr 14, 2020 0
Participant ,
Apr 14, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Apr 14, 2020 0