PDA

View Full Version : Dynamic Cropping


skinnykid
06-10-2005, 09:12 PM
So I have a workspace, which contains a picture, and a bounding box. The picture can be dragged, rotated, flipped, and scaled. within the workspace, the picture can extend outside the bounding box.

I want to have a preview window of the picture as it is cropped by the bounding box.

Right now I have two separate movie clips, and I apply the same actions to both of them, using a mask on the preview pic. All of the actions will work on both movieclips, except for the dragging.

I feel that I am using a very inefficient method for this, and was hoping for some insight.

Please see the following sites for more info:

in browser swf (http://daapspace.daap.uc.edu/~petersnh/amitademo4.html)
source fla (http://daapspace.daap.uc.edu/~petersnh/amitademo4.fla)

thanks very much,

Nathan

madgett
06-11-2005, 03:59 AM
You can only do startDrag() and stopDrag() on 1 movie clip at a time...so you need to make a way to get them both to drag. I put one in there that works. Use aStopDrag and aStartDrag from now on :).
// Use aStopDrag and aStartDrag from now on, b/c with the normal drag you can only do 1 at a time
MovieClip.prototype.aStartDrag = function(lock, left, top, right, bottom) {
this.aStopDrag();
this.__modLock__ = {x:(lock) ? 0 : this._x-this._parent._xmouse, y:(lock) ? 0 : this._y-this._parent._ymouse};
this.__lRect__ = {l:left, t:top, r:right, b:bottom};
this.__mListen__ = new Object();
this.__mListen__.parent = this;
this.__mListen__.onMouseMove = function() {
var mX = this.parent._parent._xmouse+this.parent.__modLock_ _.x;
var mY = this.parent._parent._ymouse+this.parent.__modLock_ _.y;
if (this.parent.__lRect__.l != undefined && mX<this.parent.__lRect__.l) {
mX = this.parent.__lRect__.l;
}
if (this.parent.__lRect__.t != undefined && mY<this.parent.__lRect__.t) {
mY = this.parent.__lRect__.t;
}
if (this.parent.__lRect__.r != undefined && mX>this.parent.__lRect__.r) {
mX = this.parent.__lRect__.r;
}
if (this.parent.__lRect__.b != undefined && mY>this.parent.__lRect__.b) {
mY = this.parent.__lRect__.b;
}
this.parent._x = mX;
this.parent._y = mY;
};
this.__mListen__.onMouseMove();
Mouse.addListener(this.__mListen__);
};
MovieClip.prototype.aStopDrag = function() {
Mouse.removeListener(this.__mListen__);
delete this.__mListen__;
};
Here's the file...:)

skinnykid
06-11-2005, 07:06 PM
hey madgett,

thank you very much. i appreciate the file too. :)

skinnykid
06-13-2005, 02:52 PM
Hello Again,

The code works great, but I still have a small problem. I need the two MC's to move at a ratio to one another. (the small MC moves 34% of the distance that the large MC moves, in both x and y)

I tried making a second aStartDrag function and modifying it, but I have had no luck thus far. Any help would be greatly appreciated.

Thank you,

Nathan