-
draggable objects get stuck on pointer when release over movie clip
Hi, hope someone can help. i've got movie clips that can be dragged around scene and perform a hit test when dropped over the correct target. however, if i release the object over another movie clip that isn't the correct target, the object im dragging gets stuck on the mouse pointer and i have to move the pointer to an empty area and double click to release
im using the following...
Code:
object_mc.onPress=function(){
object_mc.startDrag();
}
object_mc.onRelease=function(){
object_mc.stopDrag();
any ideas? thanks. x
-
Senior Member
Originally Posted by quaker_kid
Hi, hope someone can help. i've got movie clips that can be dragged around scene and perform a hit test when dropped over the correct target. however, if i release the object over another movie clip that isn't the correct target, the object im dragging gets stuck on the mouse pointer and i have to move the pointer to an empty area and double click to release
im using the following...
Code:
object_mc.onPress=function(){
object_mc.startDrag();
}
object_mc.onRelease=function(){
object_mc.stopDrag();
any ideas? thanks. x
Add in a onReleaseOutside handler as well:
Code:
object_mc.onReleaseOutside = object_mc.onRelease = function(){
object_mc.stopDrag();
}
Should do the trick.
d.
-
thanks for the reply, although this helped in preventing the object from sticking when released over an irrelevant mc, now when i drop it over a target mc it sticks. any ideas?
ta
-
Senior Member
Originally Posted by quaker_kid
thanks for the reply, although this helped in preventing the object from sticking when released over an irrelevant mc, now when i drop it over a target mc it sticks. any ideas?
ta
Hmmm. What's your code for checking on a target mc? It sounds like somthing there is overriding the onRelease handler.
If you'd like, upload the Fla and I can take a look.
d.
-
cheers mate. the fla is too big to upload on here but i've attached the swf so u can see whats going wrong. im not sure why the axe gets stuck on objects but the cow doesn't. heres the code im using...
for the cow
Code:
cow_y=cow_mc._y;
cow_x=cow_mc._x;
cow_mc.onPress=function(){
cow_mc.startDrag();
noise=new Sound();
noise.attachSound("moo")
noise.start()
}
cow_mc.onRelease=function(){
cow_mc.stopDrag();
if(cow_mc.hitTest(inv_mc)==true){
_global.cow="1";
cow_mc._visible = false;
cow1_mc._visible = true;
}else{
cow_mc._y=cow_y;
cow_mc._x=cow_x;
}
}
and the axe...
Code:
axe_y=axe_mc._y;
axe_x=axe_mc._x;
axe_mc.onPress=function(){
axe_mc.startDrag();
}
axe_mc.onRelease=function(){
axe_mc.stopDrag();
if(axe_mc.hitTest(inv_mc)==true){
_global.axe="1";
}else if(axe_mc.hitTest(cow_mc)==true){
attachMovie("jack2","jack2a",24)
jack2a._y=190;
jack2a._x=270;
axe_mc._y=axe_y;
axe_mc._x=axe_x;
}else{
axe_mc._y=axe_y;
axe_mc._x=axe_x;
}
if(_global.axe=="1"){
axe1_mc._visible=true;
axe_mc._visible=false;
}
}
when i tried the object_mc.onReleaseOutside = object_mc.onRelease = function(){ the axe couldn't be placed in the inventory and got stuck on the mouse pointer.
-
Last edited by quaker_kid; 04-27-2007 at 08:41 PM.
-
i see now that the reason the cow works and not the axe is due to arrangement. cow is on top, axe below.
-
i'm still struggling with this. can anyone help??
-
Senior Member
Originally Posted by quaker_kid
i'm still struggling with this. can anyone help??
The .swf will not load thorough Tripod, so I can't view it. Without seeing the Fla file, I can only guess at what might be wrong. I noticed this:
Code:
if(_global.axe=="1"){
axe1_mc._visible=true;
axe_mc._visible=false;
}
}
Is it possible that axe1_mc is what's stuck on the mouse, not axe_mc?
Again, without seeing the whole context of the file, I can only guess.
Hope this helps.
d.
-
appreciate the help dlowe.
Where's a good place to upload these files?
axe_mc, cow_mc and can_mc are all objects on scene.
axe1_mc and cow1_mc are inventory objects. all objects seem to get stuck if released ontop of one another, unless the dropped object is arranged higher than the target object.
cheers
-
-
Senior Member
Originally Posted by quaker_kid
appreciate the help dlowe.
Where's a good place to upload these files?
axe_mc, cow_mc and can_mc are all objects on scene.
axe1_mc and cow1_mc are inventory objects. all objects seem to get stuck if released ontop of one another, unless the dropped object is arranged higher than the target object.
cheers
Ah, yes. I think I know the problem.
When you rollover a button that is above another button it "overrides" (for lack of a better term) the handlers on the button that's underneath. Conceptually, you can only have one button event active at a time (technically a mouse handler, but who's counting?).
So what's happening is this:
1. You click on a clip and startDrag.
2. You roll over another clip that's above, and it "clears" the handlers on the button beneath it, so the onRelease event never fires.
Probably the best way to solve this is to use a swapDepths on your onPress event so that the active clip is always on the highest possible level.
Hope this helps.
d.
-
ah rite, that would explain it. i'll give your suggestions a go tomorrow. thanks for all the help mate.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|