Drag and scale

Code Actionscript 2.0

Instance action

on (press) {
mousepressed = 1;
}
on (release, releaseOutside) {
mousepressed = 0;
}
onClipEvent (enterFrame) {
if (mousepressed == 1) {
this._width = _root._xmouse - this._x;
this._height = _root._ymouse - this._y;
}
}

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); pic.addEventListener(MouseEvent.MOUSE_DOWN, press); pic.addEventListener(MouseEvent.MOUSE_UP, release); stage.addEventListener(MouseEvent.MOUSE_UP, releaseOutside); var mousepressed; function press(e:MouseEvent) { mousepressed = 1; } function release(e:MouseEvent) { mousepressed = 0; } function releaseOutside(e:MouseEvent) { mousepressed = 0; } function enterFrame(event:Event) { if (mousepressed == 1) { pic.width = mouseX - pic.x; pic.height = mouseY - pic.y; } } // image cc by http://www.flickr.com/photos/indigoprime/

Description

When the mouse clicks on the picture, the proportions are stretched to match the position of the mouse. Because the dimensions of the picture are determined by the enterFrame-handler, it can be continuously modified as the mouse is pressed and dragged throughout the frame.

related to: Drag and scale proportionally

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share