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




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:



ActionScript.org Forums > Flash General Questions > Other Flash General Questions
Posted on: 05-04-2007, 01:09 PM


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 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

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

Drop Target Game Help
im trying to make a game in which u have to catch "target" which drops from the top of the window ... but im stuck in the drop target part .. i have the following code in my frame :



PHP Code:



stop();

function initGame() {
    // the range of falling targets clips
    firstTarget = 1;
    lastTarget = 0;


    // set the number of targets to fall
    totalTargets = 25;

    // init the speed and time delay
    timeSinceLastTarget = 0;
    TargetSpeed = 5;

}
    



function dropNewTarget() {
    // drop only if it has been long enough
    if (timeSinceLastTarget > 20) {

        // drop only if there are more targets
        if  (lastTarget < totalTargets) {

            // drop only 10% of the time
            if (Math.random() < .1) {

                // create next apple and set its locations
                lastTarget++;
                attachMovie( "Target", "Target"+lastTarget, lastTarget );
                _root["Target"+lastTarget]._x = Math.random()*450+30;
                _root["Target"+lastTarget]._y = 0;

                // reset time delay for next target
                timeSinceLastTarget = 0;

                // increase target speed
                if (TargetSpeed < 10) TargetSpeed += .5;
            }
        }
    }

    // even if no target dropped, get closer to next drop
    timeSinceLastTarget++;
}

function moveTargets() {
    // loop through all existing target clips
    for (i=firstTarget;i<=lastTarget;i++) {

        // get target location
        x = _root["Target"+i]._x;
        y = _root["Target"+i]._y + TargetSpeed;

        // see whether target reached ground
        if (y > 400) {
            removeTarget(i);

        

        // continue to move target
        } else {
            _root["Target"+i]._y = y;
        }
    }
}

function removeTarget(n) {
    // take away target movie clip
    _root["Target"+n].removeMovieClip();

    // reset range of targets to move
    firstTarget = n+1;
    
    // see whether this was the last target
    if (n == totalTargets) {
        gotoAndPlay("GameOver");
    
    }





and the follwing code in an empty mc " made to just hold scripts" which is in the main timeline also


PHP Code:



onClipEvent (load) {
    _root.initGame();
}

onClipEvent (enterFrame) {
    _root.dropNewTarget();
    _root.moveTargets();





by the way the mc to be droped is named "Target"

can anyone please tell me whats wrong with it ?

help will be greatly apreciated

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

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 And Drop Game
Hi all,

I want to create a drag and drop game, where the user is presented with a choice of garphic shapes and text which they can drag and place into specified areas.
if the user wants to change thier mind then they shoudl be allowed to click a try again button,

when the have created their designs...by draggin them into the target areas...they will then have teh option of printing thier designs....

Can anyone direct me to tutorials, or source files which contain this sort of game....

The target areas will be contained within a specified box size or drawing area....

If anyone can help me ....it would be great .....thanks...

M

Drag And Drop Game
hi there, I wondering if someone can help me!
Im creating a drag and drop thing for a kids learning site but im a bit stuck! I want to drop items on multiple drop zones but can only manage to get a specific item to drop on a specific dropzone?!?!
Im prob bein stupid, can anyone help me??
HERES THE CODE i HAVE ON MY DRAGABLE MOVIECLIP:
onClipEvent (load) {
origx = this._x;
origy = this._y;
}
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.startdrag();
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.stopDrag();
if (_parent.dropzone1.hitTest(this._x, this._y, true)) {
this._x = _parent.dropzone1._x;
this._y = _parent.dropzone1._y;
}
}
thanks
Ive attached the .fla as well
Neil.

Help With Drag And Drop Game
Hi all,

Im really stumped. This will be easiest to explain if you take a look at the game I’m developing…

Its here

You’ll notice that as you drag the med to its correct pill bottle, they get checked off under the corresponding bottle. That works fine. My question is how do I make the users first correct answer show at the top of the list?

So in looking at the example haldol and thorazine are anti-psychotics. If I drop haldol in first great because the haldol text field is in first position. But what if I drag thorazine in first? I want Thorazine to be in the first position on the list.

Heres my code for the haldol_mc:

code: //code for psychotic meds
haldol_mc.onPress = function(){
startDrag(this);
feedback_txt.text = "";
//open pill bottles onPress
tarpsychotic_mc.pillbottle_mc.gotoAndStop(2)
tarmood_mc.pillbottle_mc.gotoAndStop(2)
taranxiety_mc.pillbottle_mc.gotoAndStop(2)
tardepressants_mc.pillbottle_mc.gotoAndStop(2)
}

haldol_mc.onRelease = function(){
stopDrag();
//close pill bottles onRelease
tarpsychotic_mc.pillbottle_mc.gotoAndStop(1)
tarmood_mc.pillbottle_mc.gotoAndStop(1)
taranxiety_mc.pillbottle_mc.gotoAndStop(1)
tardepressants_mc.pillbottle_mc.gotoAndStop(1)
if(this.hitTest(tarpsychotic_mc)){
feedback_txt.textColor = 0x00CC00
feedback_txt.text = "Correct!"
haldol_mc._visible = false;
haldol_txt.text = "Haldol"
checkhaldol_mc._visible = true;
myCorrectSound.attachSound("correct");
myCorrectSound.start();
}else{
setProperty(this, _x, 191.3)
setProperty(this, _y, 76)
feedback_txt.textColor = 0xFF0000
feedback_txt.text = "Incorrect, try again";
myIncorrectSound.attachSound("incorrect");
myIncorrectSound.start();
}
}

Any ideas on how I can go about doing this? I’ve looked at loops, and arrays but cant seem to come up with something that works. Any ideas are greatly appreciated. Thanks

Greg

[F8] Drag And Drop Game
Hey all you Flash Guru's!!

I have a question about making a graphic disappear after it's been paired with it's corrisponding graphic. I making a game for an education site, in which you drag the answer in the question it refers to.

I have been able to code up pretty much everything, except being able to make the object dragged disappear after it's been matched

Also, I was hoping if sombody would know a way to make it so the graphic would snap back to it's place if dragged and let go

Thank-you!

p.s I just trying to get the code to work, then everything will change in better graphics.

Drag And Drop Game :(
ok im using this script in a drag and drop game...



function dragSetup(clip, targ) {
clip.onPress = function() {
startDrag(this);
this.beingDragged=true;
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged=false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
_root.targ.gotoAndStop(2);
} 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;
//the variables below will store the clips end position
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
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;
}
};
}

dragSetup(circle_mc,targetCircle);
dragSetup(circle2_mc,targetCircle2);
dragSetup(circle3_mc,targetCircle3);



however... i cant get my clips to go to frame 2 when they hit their targets...
so i think theres something wrong with this bit...

if (eval(this._droptarget) == targ) {
this.onTarget = true;
_root.targ.gotoAndStop(2);
} else {
this.onTarget = false;
_root.targ.gotoAndStop(1);
}

any ideas?

Drag And Drop Game
Hi There

I'm currently making a point and click game and I've used seperate classes and I've made an array (which is called inventory.as) which stores objects/items whenever I click on them. I'm having some issues dragging the objects from the array and onto other objects. I'm also wanting to save the objects once the're in the array so if a particular object doesn't fit with another object (eg a key doesn't fit a door) it will return back to the array. Is there anyone out their that could point me in the right direction.

Cheers

Prooster

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