00:00
00:00
Newgrounds Background Image Theme

kkolo just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Drag & Drop

10,157 Views | 55 Replies
New Topic Respond to this Topic

Response to AS: Drag & Drop 2006-04-09 19:05:11


OK maybe if I explain more I can get some help:P

I have an MC within a button... on the button's actions, I have the foollowing code for dragging...

on (press) {
if (_global.candrag == true) {
startDrag("blah");
}
}
on (release, releaseOutside) {
this.stopDrag();
}

This works fine... but!

Is it possible to have it so that, if the button that I'm dragging comes into contact with another MC "wall", it is impossible for the two to overlap? So instead of being dragged over this other MC, the dragging object is 'forced' to stay outside of the perimiter of this MC "wall"?

Thanks in advance...

Response to AS: Drag & Drop 2006-04-10 04:43:51


................ no-one? :)

Response to AS: Drag & Drop 2006-04-10 14:32:09


ive never tried drag and drog before ---the mouse movement of the items n tha are working-buh every thing on the stage is moving as well?

Response to AS: Drag & Drop 2006-04-10 18:05:07


No, the drag works perfectly:) the only problem is as I described above, what I'm trying to achieve...

Response to AS: Drag & Drop 2006-04-12 11:44:22


Anyone care to help me please?

Just read the previous posts for my problem:)thanks.

Response to AS: Drag & Drop 2006-04-12 17:03:48


..........................................
............... anyone? :) As I said, I'd much appreciate some help.

Response to AS: Drag & Drop 2006-04-12 17:25:45


Just an idea.

if(this.hitTest(_root.wall){
stopDrag();
}

Paste it somewhere in your MC. I thought i should post since youve asked so many itme, lol.

Explanation

If the object hits the wall you can't drag it. you probably already new this.

P.S. i wouldn't post on old AS:Threads for help. You nearly never get help. Exept me, i'm teh best, lol.


BBS Signature

Response to AS: Drag & Drop 2006-04-12 17:28:26


And Evil entity, you must make sure your saying what you want to frag. Btw why does no one put this on a mc?

on(press){
startDrag("");
}
on(release){
stopDrag();
}
THis way has always worked for me, on a mc, not a button.


BBS Signature

Response to AS: Drag & Drop 2006-04-12 17:43:52


Hmhmhmh... thanks very much for your help:)but it doesn't seem to work.....

I've got my Button (for dragging code) inside the MC, with......

onClipEvent (load) {
if (this.hitTest(_root.wall)) {
stopDrag();
}
}

And the code for the button inside the MC, is

on (press) {
startDrag("box1");
}
on (release) {
stopDrag();
}

It drags fine, but continues to drag even on contact with the wall MC...

Any thoughts?

Response to AS: Drag & Drop 2006-04-12 17:46:17


Yeah I don;t know why I use a button...

I was told that a while ago... so I continued doing it...

Or maybe I'm just dumb:P

I'll try your code on the MC

Response to AS: Drag & Drop 2006-04-12 17:49:46


At 4/12/06 05:43 PM, Tolomus wrote: Any thoughts?

1. Stop bumping this topic, how about you make a new topic dipshit.
2.
onClipEvent (load) {
if (this.hitTest(_root.wall)) {
stopDrag();
}
}
clip event's can only be on movieclips
3.
onClipEvent (load) {
what do you think this line means? when the clip LOADS so when the clip load's the actions will happen,
use onClipEvent(enterFrame){
so that it will update every second.
4. stop being annoying.


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Response to AS: Drag & Drop 2006-04-12 17:50:00


OK I then put

onClipEvent (load) {
if (this.hitTest(_root.wall)) {
stopDrag();
}
}
on(press){
startDrag("");
}

on(release){
stopDrag();
}

This on a single MC and it still doesn't stop me from dragging this over the MC 'wall'........

Response to AS: Drag & Drop 2006-04-12 17:56:26


At 4/12/06 05:49 PM, -Vengeance- wrote:
At 4/12/06 05:43 PM, Tolomus wrote: Any thoughts?
1. Stop bumping this topic, how about you make a new topic dipshit.
2.
onClipEvent (load) {
if (this.hitTest(_root.wall)) {
stopDrag();
}
}
clip event's can only be on movieclips
3.
onClipEvent (load) {
what do you think this line means? when the clip LOADS so when the clip load's the actions will happen,
use onClipEvent(enterFrame){
so that it will update every second.
4. stop being annoying.

1. I thought one reason of having these AS topics was to cut down on many repeated threads with similar/same question or problems... thats why I'm bumping this thread, and mabye someone with a similar problem as mine will see this.

2. I know.

3. No need to be an ass... I appreciate the help, and the (enterframe) seemed to be the problem... I didn't know that (load) doesn't update every frame (yes I'm pretty new at AS)

4. Stop being rude/ass-ish.

Response to AS: Drag & Drop 2006-04-18 11:17:12


this is a complicated way. i make an MC, give it this code:

on (press) {
startDrag(this);
}
on (release) {
stopDrag();
}

and no problems were had.

Response to AS: Drag & Drop 2006-07-18 10:51:05


i use that very same code on mine it seems only to work on my flash mx though


PM me for a Signature. | Add me on Steam: Sneakers25

Response to AS: Drag & Drop 2006-12-20 12:21:25


Me got question. k.. What is the code for rotating the mc when you drag it?


Happy ALT for "hotdog-productions"! :)

Response to AS: Drag & Drop 2006-12-20 14:00:34


Common guys.. Wtf?


Happy ALT for "hotdog-productions"! :)

Response to AS: Drag & Drop 2007-03-02 11:38:01


... I'm trying to create a dress up game. I got the click and drag to work, but it drags everything in the flash. How can I set it up so that only what is clicked moves, not everything else?

Response to AS: Drag & Drop 2007-03-02 11:41:51


You are currently calling it upon the main stage, you must call it on the item that called the mouse-press event.

one.onPress = two.onPress = three.onPress = function () { this.startDrag (); };


BBS Signature

Response to AS: Drag & Drop 2007-03-02 12:25:29


At 3/2/07 11:41 AM, GustTheASGuy wrote: You are currently calling it upon the main stage, you must call it on the item that called the mouse-press event.

one.onPress = two.onPress = three.onPress = function () { this.startDrag (); };

Thanks. That fixed it.

Response to AS: Drag & Drop 2008-01-03 17:13:49


hi guys. Im looking for a tut on how to click on something, make it into my mouse, till I click on something else, for a basic point and click adventure game. Im not sure what to call it, is it drag and drop or is it something else? If I knew what to call this function I might be able to find it cause it must be a common need of gamers...

ta

Response to AS: Drag & Drop 2008-03-31 21:34:42


At 9/28/05 06:19 PM, daypack wrote: I'm using the code:

on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}

I paste this into a button and then convert it to a mv. It this right? Could you tell me why the stage drags with, for future ref?

Day Pack, If you havent solved your problem yet, it is simple, Buttons are pre-assigned to affect the main timeline, I found that out the hard way, just make the item a movieclip and put:

onClipEvent(mouseDown){// when the mouse is pressed
if(this.hitTest(_root._xmouse,_root._ymo use,true)){// if the clothing is touching the mouse
startDrag(this)// follow the mouse
this.swapDepths(9999)// bring to the top of everything else
}
}
onClipEvent(mouseUp){//when the mouse is released
stopDrag()// stop following the mouse
}
onClipEvent(

Response to AS: Drag & Drop 2008-03-31 21:45:13


At 1/3/08 05:13 PM, crazyoval wrote: hi guys. Im looking for a tut on how to click on something, make it into my mouse, till I click on something else, for a basic point and click adventure game. Im not sure what to call it, is it drag and drop or is it something else? If I knew what to call this function I might be able to find it cause it must be a common need of gamers...

ta

Crazyoval, please read and actually understand this before you just copy it...

what you need is somewhat like startDrag but not quite: try this

I am only showing you for two objects but you could probably understand it and adapt it for more:

OBJECT1 (named object1)=
onClipEvent(load){
var using:Boolean=false
var initx=this._x
var inity=this._y
}
onClipEvent(mouseDown){
if(this.hitTest(_root._xmouse,_root._ymo use,true)){
if(using==false){
using=true
_root.object2.using=false
}else{
if(using==true){
using=false
}
}
}
onClipEvent(enterFrame){
if(using==true){
this._x=_root._xmouse
this._y=_root._ymouse
Mouse.hide()
}else{
if(using==false){
this._x=initx
this._y=inity
}
}

OBJECT2 (named object2)=
onClipEvent(load){
var using:Boolean=false
var initx=this._x
var inity=this._y
}
onClipEvent(mouseDown){
if(this.hitTest(_root._xmouse,_root._ymo use,true)){
if(using==false){
using=true
_root.object1.using=false
}else{
if(using==true){
using=false
}
}
}
onClipEvent(enterFrame){
if(using==true){
this._x=_root._xmouse
this._y=_root._ymouse
Mouse.hide()
}else{
if(using==false){
this._x=initx
this._y=inity
}
}

Response to AS: Drag & Drop 2008-08-01 14:45:27


Somebody can pm me saying a script that work well?

Response to AS: Drag & Drop 2008-10-05 09:59:57


hey, question, is there any way to add the same actionscript to multiple items at once?


Suck it.

Response to AS: Drag & Drop 2008-10-18 17:55:46


im making a scene creator type game which has a few movie clips for some of the dragging things. To make the game look better i've got a mate to design some menus that slide open when you click them, and that works well, ut when i put the movie clip onto them, they dont work. I've tried changing the start drag part (startdrag"/menu/movieclip") on all of the scripts on the movie clip and the buttons inside it, but that doesnt seem to be working. when i do it with simple buttons that are only inside the menu (as opposed to another movie clip) it does work, so i dont know what im doing wrong
help?


Yeah, I went there