|
-
Angkor-What?
Drag/resizable square
Hi all,
I'm working on an application to play around with images. In which I want to make something like the selection tool in Photoshop. What I want to do is, once the selection tool is selected, for users to click anywhere on the image, this way they start the selection square. The square automatically resizes along with the mouse movement. Once they release the mouse button the square will be fixed and not resize anymore. I've been playing around with it but I can't get it to work. This is what I have;
Code:
this.attachMovie("drag_square", "drag_square", 1000000);
_root.drag_square._visible = false;
_root.child_holder.onMouseDown = function() {
_root.drag_square._width =0;
_root.drag_square._height =0;
_root.drag_square._visible = true;
_root.drag_square._x = _root.child_holder._x+_root.child_holder._xmouse;
_root.drag_square._y = _root.child_holder._y+_root.child_holder._ymouse;
};
_root.child_holder.onMouseMove = function() {
_root.drag_square._width = _root._xmouse-_root.drag_square._x;
_root.drag_square._height = _root._ymouse-_root.drag_square._y;
};
The problems are;
The square starts anywhere on stage, eventhough I set _root.child_holder.onMouseDown and not Stage.onMouseDown or something.
And the function continues after releasing the mousebutton. is there a function to use in stead of _root.child_holder.onMouseMove, something like
_root.child_holder.onWhileMouseDown?
Cheers
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
-
Can't Re-Member
-
Angkor-What?
Thanx alot! It helped a lot... my code is now:
Code:
this.attachMovie("drag_square", "drag_square", 1000000);
_root.drag_square._visible = false;
_root.child_holder.onPress = function() {
_root.drag_square._width =0;
_root.drag_square._height =0;
_root.drag_square._visible = true;
_root.drag_square._x = _root.child_holder._x+_root.child_holder._xmouse;
_root.drag_square._y = _root.child_holder._y+_root.child_holder._ymouse;
this.onMouseMove = function() {
_root.drag_square._width = _root._xmouse-_root.drag_square._x;
_root.drag_square._height = _root._ymouse-_root.drag_square._y;
};
};
_root.child_holder.onRelease = _root.child_holder.onReleaseOutside = function() {
delete this.onMouseMove;
};
And it works perfectly! I didn't know I could add functions like onPress and stuff, thought only onMouseDwon, onMouseUp, onMouseMove were posible. Also, delete this.onMouseMove; is something I didn't think of!
Thanx mate!
Cheers
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|