PDA

View Full Version : Strange cursor



Gooo
April 13th, 2009, 01:09 AM
Hi

I made a custom cursor - namely "cursor_mc".
There are also 2 movie clips on my stage, - "but_mc" and "block_mc".
When but hits block, it should play frame 133.

My question:
If I click on but and drag it to block, everything works perfectly, but when I click on but and release it somewhere else (not on block), my cursor disappears.

Why would something like this happen?

My code:
stop();
Mouse.hide();
cursor_mc.startDrag(true);

but_mc.addEventListener(MouseEvent.MOUSE_DOWN, startbut);
function startbut(event:MouseEvent):void
{
but_mc.startDrag();
}

but_mc.addEventListener(MouseEvent.MOUSE_UP, stopbut);
function stopbut(event:MouseEvent):void
{
but_mc.stopDrag();
if (but_mc.hitTestObject(block_mc))
{
gotoAndPlay(133);
}
}

Can someone please help me?

Thanks

DFdou
April 13th, 2009, 02:27 AM
function stopbut(event:MouseEvent):void {
but_mc.stopDrag();
if (but_mc.hitTestObject(block_mc)) {
gotoAndPlay(133);
}else{
cursor_mc.startDrag(true);
}
}
maybe this meet your needs

Gooo
April 13th, 2009, 03:10 AM
Thanks for your reply, but it still doesn't work.

I'm attaching a .fla file, so that you can see the example that I am referring to.

DFdou
April 14th, 2009, 02:33 AM
stop();

Mouse.hide();
e.startDrag(true);

but_mc.addEventListener(MouseEvent.MOUSE_DOWN, starte);
function starte(event:MouseEvent):void
{
but_mc.startDrag();
}

but_mc.addEventListener(MouseEvent.MOUSE_UP, stope);
function stope(event:MouseEvent):void
{
but_mc.stopDrag();
if (but_mc.hitTestObject(block_mc))
{
gotoAndPlay(2);
}else{
e.startDrag(true);
}
}
these codes work well,,,
this doesn't meet your needs?
1.dray e,
2.if but_mc.hitTestObject(block_mc),goto2
3.else but_mc.stopDrag,and e.startDrag(true);?

Gooo
April 14th, 2009, 03:32 AM
Thanks, but why does the new cursor image stay behind if I drag the but_mc? What else can I try?

DFdou
April 14th, 2009, 04:23 AM
stop();

Mouse.hide();
e.startDrag(true);

but_mc.addEventListener(MouseEvent.MOUSE_DOWN, starte);
function starte(event:MouseEvent):void
{
but_mc.startDrag();
this.swapChildren (but_mc,e);
}

but_mc.addEventListener(MouseEvent.MOUSE_UP, stope);
function stope(event:MouseEvent):void
{
but_mc.stopDrag();
this.swapChildren (e,but_mc);
if (but_mc.hitTestObject(block_mc))
{
gotoAndPlay(2);
}else{
e.startDrag(true);
}
}
try this..

Gooo
April 15th, 2009, 01:39 AM
I found out what was wrong. The custom cursor had to look like this:

import flash.events.MouseEvent;
addEventListener(MouseEvent.MOUSE_MOVE, gotomouse);
function gotomouse(event:MouseEvent) {
e.x = mouseX;
e.y = mouseY;
e.visible = true;
Mouse.hide();
}

But thanks for the replies.