Go Back   kirupaForum > Flash > Game/AI Programming

Reply
 
Thread Tools Display Modes
Old 10-11-2009, 02:02 PM   #1
gdz1982
Registered User
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?
Attached Files
File Type: zip draggame.zip (5.2 KB, 2 views)
gdz1982 is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 10-11-2009, 04:05 PM   #2
flyingmonkey456
I'll steal your dog.
 
flyingmonkey456's Avatar
Location The Land of Oz

Posts 396
Quote:
Originally Posted by gdz1982 View Post
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.
flyingmonkey456 is offline   Reply With Quote
Old 10-11-2009, 05:12 PM   #3
therobot
Block user.
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 );
}
therobot is offline   Reply With Quote
Old 10-11-2009, 05:16 PM   #4
gdz1982
Registered User
Quote:
Originally Posted by flyingmonkey456 View Post
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.

gdz1982 is offline   Reply With Quote
Old 10-11-2009, 06:40 PM   #5
flyingmonkey456
I'll steal your dog.
 
flyingmonkey456's Avatar
Location The Land of Oz

Posts 396
will the zone always be square?
flyingmonkey456 is offline   Reply With Quote
Old 10-11-2009, 06:43 PM   #6
neilmmm
Registered User
 
neilmmm's Avatar
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..
neilmmm is offline   Reply With Quote
Old 10-13-2009, 05:22 PM   #7
gdz1982
Registered User
ah yes.... i'm still newbie at this thus i'm always confused when you give me help like the poster above , thanks anyway, goshdarn, it's so hard...
gdz1982 is offline   Reply With Quote
Old 10-13-2009, 07:02 PM   #8
neilmmm
Registered User
 
neilmmm's Avatar
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
Attached Files
File Type: fla drag to fixed position.fla (32.0 KB, 3 views)

Last edited by neilmmm; 10-13-2009 at 07:06 PM..
neilmmm is offline   Reply With Quote
Old 10-14-2009, 01:59 AM   #9
gdz1982
Registered User
yes it helps very much , though.. is this AS 3? cause not seen yet movieclip.onpressfunction yet in the codes i browse...
but as long as it works , it's okay!
thanks and hugs!
gdz1982 is offline   Reply With Quote
Old 10-14-2009, 09:48 AM   #10
neilmmm
Registered User
 
neilmmm's Avatar
it is as2
neilmmm is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:19 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com