10-11-2009, 02:02 PM
|
#1
|
|
|
Trap the draggable object
Hello there, i need your advice , currently i am working on lil application where i need a draggable object which MUST be 'trapped' in a certain area
, it can be either set zone or inside a movie clip or trapped surrounded by other movie clips.
i tried hitTest attached to separete movie clip which would stop draggable file from moving but it didnt worked ,but it didnt worked so far... could you help?
|
|
|
10-11-2009, 04:05 PM
|
#2
|
|
|
Quote:
Originally Posted by gdz1982
Hello there, i need your advice , currently i am working on lil application where i need a draggable object which MUST be 'trapped' in a certain area
, it can be either set zone or inside a movie clip or trapped surrounded by other movie clips.
i tried hitTest attached to separete movie clip which would stop draggable file from moving but it didnt worked ,but it didnt worked so far... could you help?
|
i'm not entirely sure what you're asking, but it sounds like you want an object to move towards the mouse and to collide with objects. that's pretty simple, i think your problem is that you're thinking about them as the same thing when they aren't. search for tutorials on how to do each of those separately.
|
|
|
10-11-2009, 05:12 PM
|
#3
|
|
|
I think what you're trying to do should be built into Flash.
You should be able to confine movement to certain area whilst dragging a MovieClip around - check out the documentation for startDrag to see if this is what you're talking about :
http://livedocs.adobe.com/flash/9.0/...tartDrag%28%29
__________________
you = function(){
setEnabled( true );
live();
setEnabled( false );
}
|
|
|
10-11-2009, 05:16 PM
|
#4
|
|
|
Quote:
Originally Posted by flyingmonkey456
i'm not entirely sure what you're asking, but it sounds like you want an object to move towards the mouse and to collide with objects. that's pretty simple, i think your problem is that you're thinking about them as the same thing when they aren't. search for tutorials on how to do each of those separately.
|
no... i searched alot of tutorials but still couldnt find the right one
i want a draggable movieclip , which i did , to be inside a certain zone ,
i hope this pic will help.. my english is still wonky i see.

|
|
|
10-11-2009, 06:43 PM
|
#6
|
|
|
startDrag (MovieClip.startDrag method)
public startDrag([lockCenter:Boolean], [left:Number], [top:Number], [right:Number], [bottom:Number]) : Void
Lets the user drag the specified movie clip. The movie clip remains draggable until explicitly stopped through a call to MovieClip.stopDrag(), or until another movie clip is made draggable. Only one movie clip at a time is draggable.
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Availability: ActionScript 1.0; Flash Player 5
Parameters
lockCenter:Boolean [optional] - A Boolean value that specifies whether the draggable movie clip is locked to the center of the mouse position (true), or locked to the point where the user first clicked the movie clip (false).
left:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
top:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
right:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
bottom:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
Last edited by neilmmm; 10-11-2009 at 06:46 PM..
|
|
|
10-13-2009, 07:02 PM
|
#8
|
|
|
does this help
Code:
_mc.onPress=function () {
//this.startDrag(locks to registration point,left _x pos of stage in relation to registration point,top _y pos of stage to registration point,right _x,bottom _y)
this.startDrag(true,75,75,425,325)
}
_mc.onRelease=_mc.onReleaseOutside=stopDrag;
in the fla the registration on the dragable mc (_mc) is centered and can not escape the box it sits in
as i hard coded the draggable range it was useful to make the height and width of the mc a number that could easily be halved
Last edited by neilmmm; 10-13-2009 at 07:06 PM..
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 04:19 PM.
|
|