Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Drag Abd Drop, Rollover When Drag Is Over Drop Target?



Hi, im using Flash MX 2004.

I am building a drag and drop, and I have a MC that can be dragged around the stage. The trouble im having is trying to make the drop location do something when i drag the MC over/off it.

I have the following code which works.

objectToDrag.onMouseMove = function() {
if ((objectToDrag.hitTest(dropper)) && (component._beingDragged == true)) {
dropper._alpha = 50;
temp++;
trace("working"+temp);
}
}

This will make the clip i am dragging the draggable MC over change alpha, but for the life of me I cant figure out how to get the alpha to change BACK, after the draggable MC is taken away from the 'dropper'.

Is there a better way that hitTest??

Cheerz,
Dwayne



FlashKit > Flash Help > Flash ActionScript
Posted on: 05-02-2006, 02:08 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Drag&Drop Duplicate Movie With Drop Target
Hi There...

I'm creating a game where people can design their own cell phone by adding diamonds to it, a "Bling Phone" if you will. You will be able to add 4 types of diamonds to it, change the phones skin, add music to it, give it a name etc etc

I've got it to a stage where it when you click on a diamond(mc) on the stage it duplicates a hidden diamond(mc with a button inside) off stage and you can drag it around etc and then click save. Theres a script which grabs the instance name, x and y position of every diamond on the stage and stores it into a multi dimensional array which will be fed into a mysql database for retreival purposes at a later date.

Now my problem is i would like to be able to use the phone(mc) as a drop target but i'm not sure where to put the droptarget script. does it go on the original MC diamond or the duplicated mc diamond with the button inside it ?

Once a diamond has been dropped onto the phone i would also like it if the user then drags the diamond off the phone it gets deleted. I think i've got it half working but my variables which keep track how many diamonds are on stage dont appear to be updating.

I've attached the .fla file to this post if some is interested in taking a look and helping me out. The droptarget script is only on the blue diamond so far.

Any help would be much appreciated.

Thanks

Rob

Drag And Drop - Multiple MC's On To A Single Drop Target
Hi All

I am struggling with a drag and drop excercise.

I have 15 movie clips that need to be dragged over a single drop target in a specific order. i.e 1,2,3,4, when the correct movie clip is dragged to the drop target a movie within the drop target needs to advance a single frame to display the result of the correct movie clip being dragged over the drop target.

Would I be correct in thinking I need to use some kind of array to compare the clip that is being dragged to the frame position of the drop target?

I have the bones of this working and need advice / help on getting the clips to work in the specific order required. I can post my code if needed.

Thanks in advance.

btw - am using Flash MX 2004 Professional

Drag And Drop To Any Drop Target
Hi guys....I am trying to create some more generic code for a project im on....infact you guys have already helped me lots in getting it up and running!

I have basicly got it where all the dragObjects and assigned functions within a for loop and therefore been assigned to their own dropTargets...all working fine, however a situation is needed where if a user drops a clip onto anything rather than a hit area it doesnt just register as an incorrect drop.....at the moment a drag that misses a dropTarget will be the same as one that is dropped onto an incorrect drop target and thats just a bit unfair for them as it means they have used up one of only two chances!!!

basicly I need to know if its possible to obtain using the coding style that i already have been whether a drop is onto any of the drop targets before than going to chec if its the correct one or not....sorry for the long winded talk but seemed the only way i could explain!!!

the code i'm using is below


Code:


var Xpos:Number;
var Ypos:Number;
var objects:Number = 2;
for (i = 1; i <= objects; i++) {

// assigning the on press events to the dragObjects
this["dragObject"+i+"_mc"].onPress = function() {
this.startDrag(true);
// assigning the original X and Y of the dragged clips
Xpos = this._x;
Ypos = this._y;
}

// assinging the on release events to the dragObjects
this["dragObject"+i+"_mc"].onRelease = function() {
// finding the number of the dragObject to use in the submitAnswer function
objName = this._name
dragNumber = Number(objName.substr(10, 1));
submitAnswer(dragNumber);

}

}
// function to assertain whether the drop was a successful one - whether dropObecjt1 was dragged on dropTarget1 and so on
// the number is passed from the onRealease function
function submitAnswer(dragNumber:Number) {
this.stopDrag();
// if its dropped onto its correct target then turn the button off, place ontop of its target
if (this["dragObject"+dragNumber+"_mc"].hitTest(this["dragTarget"+dragNumber+"_mc"])) {
this["dragObject"+dragNumber+"_mc"].enabled = false;
this["dragObject"+dragNumber+"_mc"]._x = this["dragTarget"+dragNumber+"_mc"]._x+50;
this["dragObject"+dragNumber+"_mc"]._y = this["dragTarget"+dragNumber+"_mc"]._y+50;
trace ("knob jockey");
} else {
// if it is dropped onto a wrong target then chuck it back to where it started!
this["dragObject"+dragNumber+"_mc"]._x = Xpos;
this["dragObject"+dragNumber+"_mc"]._y = Ypos;
}
}
thanks for any help!!

Drag And Drop To Any Drop Target
Hi guys....I am trying to create some more generic code for a project im on....infact you guys have already helped me lots in getting it up and running!

I have basicly got it where all the dragObjects and assigned functions within a for loop and therefore been assigned to their own dropTargets...all working fine, however a situation is needed where if a user drops a clip onto anything rather than a hit area it doesnt just register as an incorrect drop.....at the moment a drag that misses a dropTarget will be the same as one that is dropped onto an incorrect drop target and thats just a bit unfair for them as it means they have used up one of only two chances!!!

basicly I need to know if its possible to obtain using the coding style that i already have been whether a drop is onto any of the drop targets before than going to chec if its the correct one or not....sorry for the long winded talk but seemed the only way i could explain!!!

the code i'm using is below


Code:


var Xpos:Number;
var Ypos:Number;
var objects:Number = 2;
for (i = 1; i <= objects; i++) {

// assigning the on press events to the dragObjects
this["dragObject"+i+"_mc"].onPress = function() {
this.startDrag(true);
// assigning the original X and Y of the dragged clips
Xpos = this._x;
Ypos = this._y;
}

// assinging the on release events to the dragObjects
this["dragObject"+i+"_mc"].onRelease = function() {
// finding the number of the dragObject to use in the submitAnswer function
objName = this._name
dragNumber = Number(objName.substr(10, 1));
submitAnswer(dragNumber);

}

}
// function to assertain whether the drop was a successful one - whether dropObecjt1 was dragged on dropTarget1 and so on
// the number is passed from the onRealease function
function submitAnswer(dragNumber:Number) {
this.stopDrag();
// if its dropped onto its correct target then turn the button off, place ontop of its target
if (this["dragObject"+dragNumber+"_mc"].hitTest(this["dragTarget"+dragNumber+"_mc"])) {
this["dragObject"+dragNumber+"_mc"].enabled = false;
this["dragObject"+dragNumber+"_mc"]._x = this["dragTarget"+dragNumber+"_mc"]._x+50;
this["dragObject"+dragNumber+"_mc"]._y = this["dragTarget"+dragNumber+"_mc"]._y+50;
trace ("knob jockey");
} else {
// if it is dropped onto a wrong target then chuck it back to where it started!
this["dragObject"+dragNumber+"_mc"]._x = Xpos;
this["dragObject"+dragNumber+"_mc"]._y = Ypos;
}
}
thanks for any help!!

Drag N Drop Target
Think of this question as a menu. Say I have like 7 draggable MCs, but I only have 1 target to drop these MCs into. When I drop these MCs into the target, I want it to recognize which MC is being dropped there. I can make the drag n drop just fine, I just don't know how to make the target realize which MC is on it.

Riki

Drag/drop/target - Help
I have spent the past few days hunting for a tuturial that would walk me step by step through creating a drop and drag interaction.

I have mastered drop. I have mastered drag.

I am unable to master creating the target to evaluate if it is correct or not and then resetting or providing feedback.

Any help would be appreciated !!!

Drag And Drop To Target
Could someone remind me:
I want the user to be able to drag and drop a movie clip onto another movie clip (no problem), however, if they place the first movie clip onto the wrong mc I want to prompt them to try again. If it is correct I simply want the first mc clip to stay in the correct placement and congratulate them with another "popup". I have done this before, but it has eluded me this time. Thanks a bunch.

Drag And Drop To Target
This should be easy for you pros.

How do I make a draggable ball when dropped onto a target, tell the movie to go to the next frame.

If the ball is not dropped on the correct target, I need it to return to it's original position.

Thanks,

TNBANJOMAN

Drag And Drop Is Not Quite On Target
I've created a movie clip with
1) a button inside (IPbutton)
2) a target named IP_place
3) a feedback movie clip named "feedback"

The button has the following script and when I test the movie, the button drags and drops, but "feedback" doesn't play. Any ideas on what the problem is? Do I need to specify exact coordinates for the target - and if so, how?
Thanks!

on (press) {
startDrag(IPbutton);}
on (release) {
stopDrag(); {
if (_droptarget = IP_place) {
with (feedback) gotoAndPlay(2);
}}}

[F8] Drag And Drop To Target
heya all.

hope you can help me here please.

i followed this lovely tutorial here: http://www.flashkit.com/tutorials/In...r-25/index.php

to create a jigsaw piece that when draged sits on it's appropriate target. however i have noticed that you don't have to drop it specifically on target - just touching it somewhere and the piece then becomes unmoveable. i would like to get it to sit precisely on it's target (which i will make invisible) so that all the pices can sit neatly togeter. how would i go about this?

all help recieved with gratitude.

kerry

Drag And Drop To A Target
I can do the start drag and stop drag, but how do I make sure it will align into a target area? Hit the target, so to speak.

thanks in advance

Drag & Drop On Target
Hello!
I have a problem.
I want to drag a few different numbers to a few different targetshapes. This is the code I have now:


Code:
var counter:Number = 0;
var startX:Number;
var startY:Number;

siffra_6.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
siffra_6.addEventListener(MouseEvent.MOUSE_UP, dropIt);
siffra_32.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
siffra_32.addEventListener(MouseEvent.MOUSE_UP, dropIt);
siffra_21.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
siffra_21.addEventListener(MouseEvent.MOUSE_UP, dropIt);
siffra_11.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
siffra_11.addEventListener(MouseEvent.MOUSE_UP, dropIt);
siffra_18.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
siffra_18.addEventListener(MouseEvent.MOUSE_UP, dropIt);

function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
reply_txt.text = "";
event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
}

function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);

if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
reply_txt.text = "Good Job!";

event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
} else {
reply_txt.text = "Try Again!";
event.target.x = startX;
event.target.y = startY;
}
if(counter == 4){
reply_txt.text = "Bra jobbat!";
gotoAndPlay(4);
}
}

siffra_6.buttonMode = true;
siffra_32.buttonMode = true;
siffra_21.buttonMode = true;
siffra_11.buttonMode = true;
siffra_18.buttonMode = true;
What this code does is enable the movie clips siffra_6, siffra_32... to be draged onto the targetshapes that has the correct name, and get stuck there, if the movie clips are droped somewhere else, they jump back to their original position. What I want to change is the following:
I want the movie clips siffra_6, siffra_32... to get stuck even if they are dropped on the wrong targetshape. How could that be done?
I would also like to add another function to this.
After all movie clips have been dropped I would like them to change color depending on if they are on the correct position or not.

Drag And Drop To Same Target
Can someone point me in the right direction please, ive used the code from a tutorial to drag and drop movies onto separate targets, but now want to drag movies onto the same target, and if one movie is on the target send it back to its origin.

the code from the tutorial is from monkeyflash.com

var counter:Number = 0;
var startX:Number;
var startY:Number;

square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
triangle_mc.addEventListener(MouseEvent.MOUSE_DOWN , pickUp);
triangle_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
flower_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
flower_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
pentagon_mc.addEventListener(MouseEvent.MOUSE_DOWN , pickUp);
pentagon_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);

function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
reply_txt.text = "";
event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTargetisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
reply_txt.text = "Good Job!";
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
} else {
reply_txt.text = "Try Again!";
event.target.x = startX;
event.target.y = startY;
}
if(counter == 4){
reply_txt.text = "Congrats, you're finished!";
}
}

square_mc.buttonMode = true;
flower_mc.buttonMode = true;
triangle_mc.buttonMode = true;
pentagon_mc.buttonMode = true

I have this working with 6 movies to ten targets, there must be an esier way to do this than putting all ten targets on top of each other

thanks

Andy

Drag'n'drop And Target Somewhere Else
here's the problem. i need to load a movie clip into a controlling movie. it's loaded into a holding movie clip so it can be moved. once in there, i need to drag an enclosed mc out and drop it onto the _root (not within the holding mc) so that it will stay where it is when the loaded mc is unloaded. does that make any sense?

i've tried the attachMovie and link library method, but this would be no good as loaded mc's will need to be dynamically created and made available in the controller without actively changing the controller.

there must be a way to do this in flash. anybody know?

ralpho

Drag & Drop Target
my drag and drop target works...sort of. Here's the problem, when the target is dropped it should tell the user if it is correct. It does but you have ot keep drag and dropping all over the target to finally get the answer to display. I have checked the registation marks and stage alignment...nothing seems to work. it should be if you drop it over the hit (instance name) it should immediately display the answer of "correct"

Here is the code for the drop target:

on (press) {
startDrag(this, true);
}
on (release) {
stopDrag();
if (this._droptarget == "/cat_a") {
_root.cat_a.gotoAndPlay(2);
}
}

this is the hit target:

2 frames...first says:
stop();

if (this._droptarget == "/cat_a") {
_root.cat_a.gotoAndPlay(2);
}

Second frame is the answer "correct"

there is also a second line with a stop action in the second frame

Any help would really be appreciated.

Drag Drop Target
Hello,

i'm kinda new to flash and i need some help. I'm trying to make a drag drop puzzle like this one. I can do the drag and drop bit, but does anybody know how you make a target in witch the picture can fit exact?

http://www.funzac.com/play/Photo%20Puzzle.html

For example, when you drag the picture over the area where you want to put it, but it isnt an exact fit, the puzzle itself makes it an exact fit.. If you dont know what i mean you can follow the link and than drag and drop a bit..

Thanks!

Drag & Drop Target
my drag and drop target works...sort of. Here's the problem, when the target is dropped it should tell the user if it is correct. It does but you have ot keep drag and dropping all over the target to finally get the answer to display. I have checked the registation marks and stage alignment...nothing seems to work. it should be if you drop it over the hit (instance name) it should immediately display the answer of "correct"

Here is the code for the drop target:

on (press) {
startDrag(this, true);
}
on (release) {
stopDrag();
if (this._droptarget == "/cat_a") {
_root.cat_a.gotoAndPlay(2);
}
}

this is the hit target:

2 frames...first says:
stop();

if (this._droptarget == "/cat_a") {
_root.cat_a.gotoAndPlay(2);
}

Second frame is the answer "correct"

there is also a second line with a stop action in the second frame

Any help would really be appreciated.

Drag And Drop Target
Hi,

I have drag and drop target question:
What is the main reasons that two movie clips doesn't equal when getProperty(my_mc, _droptarget)?

Plai-or
http://www.quality-web-design.netfirms.com

Drag + Drop Target.. What Am I Doing Wrong?
it just doesn't work? i've been over and over it..

i have a littlebox and a bigbox - i just want to have the bigbox play when the littlebox is dropped onto it.. i cannot even drag the littlebox at the moment though..

here is the code i put on the little box button

on (press) {
startDrag ("_root.littleBox");
}
on (release) {
stopDrag ();
if (_root.littleBox._droptarget == "/bigBox") {
_root.bigBox.gotoAndPlay("move");
}
}

the bigBox is the movieclip (target) and yes it's called bigBox
the littleBox is the button inside the movieclip called "little" and yep the button is called "littleBox" ... seriously i cannot figure out what is missing here. ?
i followed the tutorial exactly..

and i'f anyone would like to take a look at the file i'll mail it to you.
(( i'm using flash 5 and running it on an imac ))

Drag And Drop W/ Fixed Target
Hi,

I ran into some problems with the drag and drop function.

Attached is the fla. Please advice.

I created a button (embedded in 1 action script) with 4 different targets...the score on the scene would be populated based on the different value.

2 on the main scene
while 2 embedded in a movieclip.

The 2 on the scene are functioning correctly.. but not the ones in the movieclip.

this is the code my button is attached to
on (press) {
startDrag("/clip1");
}

on (release) {
stopDrag ();
if (_droptarget eq "_root.plan.target1") {
_root.score = 1;
}
if (_droptarget eq "_root.plan.target2") {
_root.score = 3;
}
if (_droptarget eq "/target3") {
_root.score = 2;
}
if (_droptarget eq "/target4") {
_root.score = 5;
}
}

Hmm.. what is the mistake on my target for target1 and target2?

PS: plan = name of mc
score <-- score tracker.

Please advise.

thanks

Drag And Drop Snap To Target
Hi
Could someone please help me with the code required to make a drag object snap onto a target(s) when in close proximity?
Many thanks

Drag And Drop Hit Target Highlight
I need help creating a drag and drop, that would have drop indicator that would let you
know where you are dropping your movieClip BEFORE you actually drop it.
This would be like in www.start.com
when you start to drag a portlet (e.g. the Weather Forecast portlet), you get a red dotted box to let you know, this is where
it's going to land when you let go of the mouse.

I have accomplished the drag and drop, but I can't seem to figure out how to create the
highlited target area to let you know, this is where your item will land when you release the mouse.
The animation in www.start.com is not necessary. I just interested in the red box highlight funtionality.

thanks
tg

Drag And Drop : Target Prob
hi
ok i have 100 movie clips on the stage cause its a board. and i have a one mc to drag and drop on the board but i dunno what target to write. usually target script looks like this :

if(this._droptarget == "/mcTarget")
this.stopDrag();

but my mcTargets are mc named tile1 - tile 100.
i dont think that i have to make everey if for 100 mc.
cheers

[F8] Drag And Drop With Target Areas
I had a go at the "Drag and Drop with Target Areas" tutorial by Peter Brouwers, and downloaded the example. I created a new one and used the example to create my own. I did what the example showed me (created four movie clips, two squares at the top, two circles at the bottom, and included the button only in the first circle, then applied some actionscript to both the frame and button).
All that was changed between the two was the instance names.

When I run my movie, the button does not drag like it should, even though the actionscript for it is the same as Peter's. I cannot understand what the difference is. If I can figure it out, then I will create a button for the second circle and create a button in it, then repeat the actionscript.

Drag And Drop Hit Target With Highlight
I need help creating a drag and drop, that would have drop indicator that would let you
know where you are dropping your movieClip BEFORE you actually drop it.
This would be like in www.start.com
when you start to drag a portlet (e.g. the Weather Forecast portlet), you get a red dotted box to let you know, this is where
it's going to land when you let go of the mouse.

I have accomplished the drag and drop, but I can't seem to figure out how to create the
highlited target area to let you know, this is where your item will land when you release the mouse.
The animation in www.start.com is not necessary. I just interested in the red box highlight funtionality.

thanks
tg

Drag And Drop Target In An Imported SWF
Hi All,
I am in a bit of a bind here, I am doing a finals for my Flash class in college and our assignment is to make a portfolio that show cases our past work, well I had made an easter egg hunt SWF where object is to find eggs and drop them into a bucket, main use of action script is the drag and drop target, By itself the SWF runs just fine but when I try to import that swf by method LoadMovie ( I am loading all my shows externally) my drag and drop target breaks. I can drag the egg over to the bucket but it dont "drop" the intial code for the drag and drop is this
code -->
on (press) {
startDrag("");
}
on(release) {

stopDrag();
if (eval(this._droptarget) == _root.EasterBasket) {
setProperty(this, _visible, false)
_root.count --;
tSound = new Sound(this);
tSound.attachSound("thump");
tSound.start(0,0);
}
}
<-- end code
I have tried using the lockroot command to keep the timelines seperate but that didnt help, I changed the _root.EasterBasket to this._parent.EasterBasket to get rid of root reference but that didnt work either. is there a better mousetrap out there that I can use for this drop and drag target that will work when it is imported to another SWF, I need help fast please, this project is due here pretty quick, thanks all, D-Wiz

Mx 2004 Drag And Drop With Target
Hi all I've been looking for a tutorial on how to create drag and drop with a defined target areas. I have seen some code over on another forum but the instructions are far from helpful really, I wondered if anyone could shed some light on where I fail to understand.

The forum link is http://www.flashkit.com/tutorials/In...r-25/index.php

I like this idea because if it isn't correct then it snaps back to original position and if correctly matched up then the object stays put.

The flash application seems simple enough but the explanation seems to fall short.

The instructions say that for the object which is 'draggable', first you should create a movie clip and then you should create button and insert this within the first keyframe of the movie clip.So ok I can create a shape and convert to movie clip but no matter what I do, I'm unable to add a button into keyframe 1 of that movie clip itself?

I have got a button thats exactly the same as the shape and have double left clicked the movie clip itself to make it selectable but when I then try to import my button from the library is always says 'cannot perform this action on an object.

I've been trying various things for 30-45 mins with no avail.

Can anyone tell me please where I'm going wrong? I did notice a drag / drop on http://www.kirupa.com/developer/acti...t/dragdrop.htm but it only applies for 2 shapes dragged over the one item.

Are there any suggestions please?

thanks in advance,
Michael

[AS3] Drag And Drop + Rollover
Hello,

I have some buttons, i need to drag and drop different movieclips on these buttons.
I use

Code:
myclip.addEventListener(MouseEvent.MOUSE_DOWN, on_mouseDownHandler);
myclip.addEventListener(MouseEvent.MOUSE_DOWN, on_mouseDownHandler,true);
and with

Code:
function on_mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;
object.startDrag();
}
i can actually drag my clip around.
The problem is that when i drag my clip over a button, the button does not rollover.
If i move the mouse over a button (without dragging my movieclip), it changes to over state

I am missing something?

My goal is to have a rollover effect on "drag over" an area (simple button in my case)

Can anyone point me in the right direction?

Thank you!

Drag And Drop Object Onto Target And Back Again
please help!
I want to be able to drag and drop an object onto a target area. If it doesn't go over target area I want it to go back to its start position.
When droped on the target area I want it to be dragable. When dragged outside the target area I want it to snap back to the origional start position.
Have had a look at Peter Brouwers tutorial on this site and so far so good except that when I drag the object out of the target area it goes to the previous position as oposed to the start position, am new to this actionscript thing and any help would be appreciated.
thanks...

Drag And Drop Target Load Movie
Im try to figure out how i would go about a certain drag and drop ,with a traget. what i want is when a user drags an icon to a specific spot on the site and release's the mouse this wil load the swf with that file in it.. if anybody would happen to know how i would do this that would be great..

Drag, Drop, Target, Play, Return
I am looking for a tutorial or the like on how to drag and drop a mc into another mc. Once this mc is drop I want it to start playing. I want to use this option to load the different sections of my site. Once a new section is chosen I also need the original selection to go back to its beginning state. Any help would be greatly appreciated. An example of what I want to do can be seen here.
http://www.trollback.com/ Thanks in advance for any help that can be offered.

Keith

Query About Drag And Drop With Target Areas
I sent an email to Peter Brouwers (p.brouwers@kw1c.nl) but it came back underliverable so I am wondering if any one else can assist me with this?

I used his tutorial on Flashkit http://www.flashkit.com/tutorials/In...r-25/index.php to create 6 draggable objects with corresponding target areas and it worked well except for the fact that I wish to allow for the user dragging the objects to their places in any order they wish as long as ultimately they are all put in the correct positions.

What code do I need to use to check if all the objects are in their correct target positions and only then the feedback sound will play. (for example if object 6 is dragged to its correct location the feedback sound will only play if the other 5 objects are also in the correct locations.)

Thanks a mil!

Newtoo

Question On Two Target Drag And Drop Files.
Hi guys, great site you have here.

Anyways here is my problem where I am stuck.

I'm making a flash project for class and I have a simple drag ang drop snapping file on a target. (a blue ball that snaps to a red square and if you miss the red square returns to it's origin)


Here is the code I have right now.



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

if (this.hitTest(_root.chris)){

_root.gotoAndStop;{this._x = 401;
this._y = 127;}
} else {

this._x = 81;
this._y = 327;
}
}


Now this code works perfect. My question is how do I add another target to the script. So if I have two targets I can drag the object to one or the other.

My second target is chris2 and I need to get it to be in x = 201 and y = 127

Any help would be great!

Thanks!!!

Drag And Drop Target On Imported SWFs
Hi All,
I am in a bit of a bind here, I am doing a finals for my Flash class in college and our assignment is to make a portfolio that show cases our past work, well I had made an easter egg hunt SWF where object is to find eggs and drop them into a bucket, main use of action script is the drag and drop target, By itself the SWF runs just fine but when I try to import that swf by method LoadMovie ( I am loading all my shows externally) my drag and drop target breaks. I can drag the egg over to the bucket but it dont "drop" the intial code for the drag and drop is this
code -->
on (press) {
startDrag("");
}
on(release) {

stopDrag();
if (eval(this._droptarget) == _root.EasterBasket) {
setProperty(this, _visible, false)
_root.count --;
tSound = new Sound(this);
tSound.attachSound("thump");
tSound.start(0,0);
}
}
<-- end code
I have tried using the lockroot command to keep the timelines seperate but that didnt help, I changed the _root.EasterBasket to this._parent.EasterBasket to get rid of root reference but that didnt work either. is there a better mousetrap out there that I can use for this drop and drag target that will work when it is imported to another SWF, I need help fast please, this project is due here pretty quick, thanks all, D-Wiz

Drag And Drop Based On Proximity To Target, Can It Be Done?
I wonder if someone can help me with a Drag and Drop problem.
I am using Flash 8.

I have used this drag n drop tutorial, http://www.flashkit.com/tutorials/In...r-25/index.php


The Problem:

I want the drag object to snap to its target based on adjustable proximity to the target. The reason for this is that my target and drag icons are small on a small cluttered stage representing a detailed map, so i would like to experiment with adjustments before commiting to a final range figure. So instead of the drag needing to be dead centre to the target, it could for example be within 50% of the centre, but still snap to the target on mouse releases.

what code would i need to insert for each drag icon?

Here is my code for the drag mc.

on (press) {
startDrag(getProperty(_x, _y));
}
on (release) {
stopDrag();
if (_droptarget eq "/TA1") {
nextFrame();
} else {
setProperty("", _y, OrgY);
setProperty("", _x, OrgX);
}
}

Drag And Drop Target On Imported Movies
Hi All,
I am in a bit of a bind here, I am doing a finals for my Flash class in college and our assignment is to make a portfolio that show cases our past work, well I had made an easter egg hunt SWF where object is to find eggs and drop them into a bucket, main use of action script is the drag and drop target, By itself the SWF runs just fine but when I try to import that swf by method LoadMovie ( I am loading all my shows externally) my drag and drop target breaks. I can drag the egg over to the bucket but it dont "drop" the intial code for the drag and drop is this
code -->
on (press) {
startDrag("");
}
on(release) {

stopDrag();
if (eval(this._droptarget) == _root.EasterBasket) {
setProperty(this, _visible, false)
_root.count --;
tSound = new Sound(this);
tSound.attachSound("thump");
tSound.start(0,0);
}
}
<-- end code
I have tried using the lockroot command to keep the timelines seperate but that didnt help, I changed the _root.EasterBasket to this._parent.EasterBasket to get rid of root reference but that didnt work either. is there a better mousetrap out there that I can use for this drop and drag target that will work when it is imported to another SWF, I need help fast please, this project is due here pretty quick, thanks all, D-Wiz

Drag And Drop Target Stuck To Mouse - Help- See Swf.
Hi, i´ve been going through some tutorials and samples of "drag and drop" flash movies and I always come apon the same bug. The drop target gets "stuck" to the mouse, and when I click the target it just drops down and doesn´t return to its orig. position. This mostly happens when the target in the "lower order" is droped behind a target that is "in front of it" Now I have used the


Code:
this.swapDepths(_root.getNextHighestDepth());
to fix the "order" problem but still the problem some times happens. - You can see the problem in the fla/swf if you drag on of the "lower order targets" under the "front targets".

Does any one know if there is a way to fix this...?

Drag And Drop Based On Proximity To Target, Can It Be Done?
Hello All, (please be gentle with me, actionscript is very new to me...)

I wonder if someone can help me with a Drag and Drop problem.

I want the drag object to snap to its target based on adjustable proximity to the target. The reason for this is that my target and drag icons are small on a small cluttered stage representing a detailed map, so i would like to experiment with adjustments before commiting to a final range figure. So instead of the drag needing to be dead centre to the target, it could for example be within 50% of the centre, but will still snap to the target when the mouse is released. The target locations will be changed for each map, and will mean that I will not have exact x,y coordinates.

what code would i need to insert for each drag icon?

Here is my code for the drag mc.

on (press) {
startDrag(getProperty(_x, _y));
}
on (release) {
stopDrag();
if (_droptarget eq "/TA1") {
nextFrame();
} else {
setProperty("", _y, OrgY);
setProperty("", _x, OrgX);
}
}

Drag & Drop Multiple Objects To 1 Target..how?
Hi there

I am just starting with AS3 and therefore please be gentle with me. I am trying to create a drag and drop learning exercise and have been using This tutorial as my base. All is fine for having 1 object dragged to 1 target but i really need to have several different objects dragged to just 1 target and i can't figure out how to do this

Any help would be greatly appreciated as i am going to need to do this a lot in the future.

cheers.

Drag - Drop Movieclip On Target- Duplicate
Hi I am new here, and to actionscript. I am working on a flash movie, and have run into a problem.

In this flash movie, you can drag the circle or square, and lock them on the smaller circle targets. What I would like to do is have a dragable duplicate made at the origin. So, say I could drag three circles, or three squares.

I have relentlessly tried to incorporate duplicateMovieclip(). But have not had any luck.

function dragSetup(clip, targArray) {
clip.onPress = function() {
startDrag(this);
this.beingDragged = true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged = false;
for (i=0; i<targArray.length; i++) {
targ = targArray[i];
if (eval(this._droptarget) == targ) {
this.myFinalX=targ._x
this.myFinalY=targ._y
this.onTarget = true;
_root.targ.gotoAndStop(2);
break;
} else {
this.onTarget = false;
_root.targ.gotoAndStop(1);
}
}
};
//the variables below will store the clips starting position
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;

clip.myFinalX = 0;
clip.myFinalY = 0;
clip.onEnterFrame = function() {
//all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
// then move the MC back to its original starting point (with a smooth motion)"
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
//if the circle is dropped on any part of the target it slides to the center of the target
} else if (!this.beingDragged && this.onTarget) {
this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;
}
};
}
allTargets = new Array(targ01, targ02, targ03);
dragSetup(circle,allTargets);
dragSetup(square,allTargets);

Drag And Drop Color Swatches To Target
Hi

I need help please. I am trying to have a row of color swatches that when one of them are dragged onto the target MC that particlar MC assimilates that swatches color. This needs to happen over and over again so that I can keep drtagging new colors over the old colors.
See pic....

Thanks so much.

redstamaster

Drag And Drop Target Stuck To Mouse - Help- See Swf.
Hi, i´ve been going through some tutorials and samples of "drag and drop" flash movies and I always come apon the same bug. The drop target gets "stuck" to the mouse, and when I click the target it just drops down and doesn´t return to its orig. position. This mostly happens when the target in the "lower order" is droped behind a target that is "in front of it" Now I have used the
Code:
this.swapDepths(_root.getNextHighestDepth());
to fix the "order" problem but still the problem some times happens. - You can see the problem in the fla/swf if you drag on of the "lower order targets" under the "front targets".

Does any one know if there is a way to fix this...?

Drag & Drop: Rollover HitTest?
Hi there. I have created a Drag & Drop quiz question that has the hitTest method on the mc's onRelease functions so that when user releases mc_question onto mc_answer an action is called. No probs there.

Can anyone tell me how to call an action when dragging mc_question OVER mc_answer?

I have attempted using an onEnterFrame hitTest function here but that stops working after the first onRelease function is called.

fla attached (exuse the graphics).

Regs

/////////////

Drop Target In "drag And Drop Game"
Im very much confused that how the code is wrong here..?on (press)
{
startDrag (this, false);
}
on (release)
{
stopDrag ();
if (_droptarget eq _root.cpu)
{
_root.score = int(_root.score + 1);

gotoAndStop(2);
}
else
{
_root.score = int(_root.score - 1);
gotoAndStop(2);
answer.gotoAndPlay("wrong");
} // end else if
}

Here im prepairing a game where i had palce this script inside a movie clip,having two option Correct amd Wrong,
I had created a box name keyboard
where an image of keyboard when placed it should show that its correct,and..if the movie clip calledkeyboardbutton is placed outside then it shoul show its wrong.
keyboardbutton is the instance name for that keyboard,
Actually its a game showing the Process of flow of operation in Computer..
Where i had also used the CPU and Monitor..please anyone help me out here...
here is a sample file for that:

Help This Is Driving Me Nuts Drag And Drop Target Problem...
Hi, hope this all makes sense...

I have a drag and drop thing going in a movie called 2004.swf which when dropped onto the defined area, loads a new swf called cheekymonkey.swf. It works when CTRL Entered. However the main movie is called portfolio.swf. It has a button in it which loads 2004.swf. When I test the portfolio.swf file and click the button to load 2004.swf, it loads fine and the button will drag, but won't load the cheekymonkey.swf when dropped.

The 2004.swf is loaded into level2
The drag button to load cheekymonkey.swf loads it into level5.

Am working in Flash MX

I know it must be a target/levels problem???

PLEASE LET ME KNOW IF ANY ADDITIONAL INFO IS NEEDED!!!

Here's the code on the button which when dropped loads cheekymonkey.swf.

---------------------------------------------------------


on (press) {
startDrag("/01");
}
on (release) {
stopDrag();
if (getProperty("/01", _droptarget) eq "/trigger") {
tellTarget ("/") {
loadMovieNum("cheekymonkey.swf", 5);
}
setProperty("/01", _x, "385");
setProperty("/01", _y, "160");
} else {
setProperty("/01", _x, "385");
setProperty("/01", _y, "160");
}
}

Duplicate Event.Target For Drag N Drop Scenario
Hello,

I'm trying to create a drag and drop scenario in Actionscript 3. When an item on the stage is clicked, that item is duplicated, and that duplicated item is dragged with startDrag().

Essentially I need to duplicate the event.target - is this possible?

Here is my code:


Code:
function duplicateitem(eventObject:MouseEvent) {
activeitem = eventObject.target;
this.addChild(activeitem);
activeitem.x=eventObject.target.x;
activeitem.y=eventObject.target.y;
activeitem.startDrag();
}

item.addEventListener(MouseEvent.MOUSE_DOWN, duplicateitem);
The above code will not work. I need to be able to actually duplicate "item", which is the "eventObject.Target"...

but if I tried something like:


Code:
var activeitem = new item();
I would then need to do this for every unique item on the stage and have a unique function for each of them which I need duplicating...

if anyone knows how to duplicate an object and then have it draggable, that would be an incredible help. thanks

[flash8] Drag And Drop / Rollover Question
Hello all

I'm working on a project that in regular english works like this:

There's a map of the U.S. There's a draggable object. The user can drag the object around over the map and drop to choose a state. When the object hovers over the map, a little label pops up that follows the object and incicates which state it's over. When the user drops the object on a state a getURL command is fired off sending the user to a site that is tailored to the region of the country that they chose.

Using the drag and drop tutorial from kirupa.com I have that functionality working. Using a hovering captions tutorial I have the rollover with the label working. However, they don't work in conjunction. When I rollover the map the labels for the states pop up and track with the mouse. But when I drag the object over the states the rollover doesn't work.

Here are some snippets from my coding. This first one is the code for the rollover labeling:

code: //caption coding
Arizona.onRollOver = function() {
captionFN(true, "Arizona", this);
this.onRollOut = function() {
captionFN(false);
};
};

Florida.onRollOver = function() {
captionFN(true, "Florida", this);
this.onRollOut = function() {
captionFN(false);
};
};

Massachusettes.onRollOver = function() {
captionFN(true, "Massachusettes", this);
this.onRollOut = function() {
captionFN(false);
};
};

Illinois.onRollOver = function() {
captionFN(true, "Illinois", this);
this.onRollOut = function() {
captionFN(false);
};
};

captionFN = function (showCaption, captionText, bName) {
if (showCaption) {
_root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
cap.desc.text = captionText;
cap._alpha = 100;
//
hoverCaption.onEnterFrame = function() {
cap._x = _root._xmouse;
cap._y = _root._ymouse;
cap._visible = true;
};
} else {
delete hoverCaption.onEnterFrame;
cap._visible = false;
}
};


//end caption coding



Here is the code that exists on the movieclip of the draggable object:

code: //drag-n-drop code
on (press) {
startDrag ("_root.dragBall" ;
}

on (release) {
stopDrag ();
if (_root.dragBall._droptarget == "/Arizona" {
_root.brandName.gotoAndStop("brandX" ;
}
if (_root.dragBall._droptarget == "/Florida" {
_root.brandName.gotoAndStop("brandY" ;
}
if (_root.dragBall._droptarget == "/Massachusettes" {
_root.brandName.gotoAndStop("brandX" ;
}
if (_root.dragBall._droptarget == "/Illinois" {
_root.brandName.gotoAndStop("brandY" ;
}
if (_root.dragBall._droptarget == "" {
_root.brandName.gotoAndStop("noDecision" ;
}
}
//end drag-n-drop code

Obviously something is missing. I'm new to actionscripting, so it's likely that I'm going about this entirely the wrong way. I'm also certain that there are probably much more efficient ways to roll all of this together. But like I said, I'm just digging into coding so I may not be thinking about this the right way yet. Here are links to the .fla and .swf respectively so you can see everything for yourselves.

Any help thinking through this is greatly appreciated!
http://www.roxorbot.com/mapTest.fla
http://www.roxorbot.com/mapTest.swf

Rollover Text On A Drag And Drop Object
Hi folks, I wondered if someone could help me with this problem. Last week I was adding text to a drag and drop object on the press of a button and release of a button. This week, I am trying to get the drag and drop object to reveal text when the mouse rolls over it and again when the mouse releases it. I thought it should be pretty easy to fathom out the script for this, because I was given a lot of help last week. But I put in the attached code, and the object does not drag and drop, and neither does it show any text when the mouse rolls over it and off it.
Can anyone tell me what I am doing wrong?

Thanking you,
Marchan







Attach Code

movieclipa.onrollOver = function() {
this.movietexta.text = 'text on roll over.';
startDrag(this);
}

movieclipa.onrollOut = function() {
this.movietexta.text = 'It works.';
stopDrag();

}
var obj_encountered = false;
trace('things in _root are:');
for(var obj in _root) {
trace('-------------------');
trace(obj + ' and it is a ' + typeof(_root[obj]));
if(typeof(_root[obj]) == 'movieclip') {
trace('and it contains:');
for(var moreobjects in _root[obj]) {
var mytype = typeof(_root[obj][moreobjects]);
if(mytype.substring(0,1) == 'o') {
var indefinite_article = 'an ';
} else {
var indefinite_article = 'a ';
}
trace(moreobjects + ' and it is ' + indefinite_article + typeof(_root[obj][moreobjects]));
if(moreobjects == 'obj') {
obj_encountered = true;
}
}
}
}
if(obj_encountered) {
trace('-------------------
-------------------
Hey - your script is in the wrong place!!!
-------------------
-------------------');
} else {
trace('-------------------
-------------------
Congratulations! Your script is in the _root!!!
-------------------
-------------------');
}

[MX04] Drag And Drop- Locking Object Into Center Of Target...
Hello all,
New member and relatively new Flash user. I created a drag and drop in Flash MX 2004, and I'm trying to find script that will lock the object into the center of the target when it is dragged over, sort of like a magnet effect. Here is the script I currently have on each object:


on(press) {
startDrag(this);
_root.reply.text="";
xstart = this._x;
ystart = this._y;
}

on(release) {
stopDrag();
if (this._droptarget == "/pinottarget") {
_root.reply.text="Correct!";
this.enabled = false;
_root.counter++;
}

else{
_root.reply.text="No, keep trying!";
this._x = xstart;
this._y = ystart;
}
}



If anybody can help me out with the correct script to do what I'm trying to do, I would greatly appreciate it. Attached is the source file. Thanks.

Lee

Copyright © 2005-08 www.BigResource.com, All rights reserved