View Full Version : Cursor in flash
dimitars
December 31st, 2007, 03:25 PM
function mousehide(event:Event)
{
Mouse.hide();
cursor.startDrag ();
}
stage.addEventListener(Event.ENTER_FRAME, mousehide);
I use this code. Anyway the new cursor(an mc) isn't matching the position of the real cursor. So how to center them?
jwopitz
December 31st, 2007, 05:57 PM
you are calling hide and startDrag on every frame. You should only have to call each of those only once and then it should be follow thereafter. That could be the reason why your mc isn't aligned because it has some hiccup that causes it to be slightly off due to the unnecessary processing taking place.
dimitars
January 1st, 2008, 07:26 AM
So how to solve this problem?
How would you make custom cursor?
seimon
January 1st, 2008, 07:45 AM
my_mc.onRollOver = function() {
Mouse.hide();
this.attachMovie("cursorId", "cursor_mc", this.getNextHighestDepth(), {_x:this._xmouse, _y:this._ymouse});
};
my_mc.onMouseMove = function() {
this.cursor_mc._x = this._xmouse;
this.cursor_mc._y = this._ymouse;
};
my_mc.onRollOut = function() {
Mouse.show();
this.cursor_mc.removeMovieClip();
};
Though this is for as 2; Hope you can find your own way to make your own cursor for as 3.
dimitars
January 1st, 2008, 09:07 AM
I'm waiting for as 3.0 custom mouse cursor:D.
p.s. Hapy new Year to all of you
tpspoons
January 1st, 2008, 12:46 PM
Mouse.hide ();
cursor.startDrag (true);
453.0
January 1st, 2008, 01:49 PM
or something like this:
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMov e)
function onMove(event:MouseEvent){
_cursor.x=event.stageX
_cursor.y=event.stageY
}
Happy new Year !
LittleFenris
January 1st, 2008, 03:55 PM
This works (I tested it)...
Mouse.hide();
cursor.startDrag();
stage.addEventListener(MouseEvent.MOUSE_MOVE,dragC ursor);
function dragCursor(e:Event)
{
cursor.x = mouseX;
cursor.y = mouseY;
}
And just make sure the registration point for the cursor movieclip is where you want the click point of your mouse to be.
tpspoons
January 1st, 2008, 03:59 PM
This works (I tested it)...
Mouse.hide();
cursor.startDrag();
stage.addEventListener(MouseEvent.MOUSE_MOVE,dragC ursor);
function dragCursor(e:Event)
{
cursor.x = mouseX;
cursor.y = mouseY;
}
And just make sure the registration point for the cursor movieclip is where you want the click point of your mouse to be.
That is what the second parameter for the startDrag () is (lockCenter).
From Livedocs (http://livedocs.adobe.com/flex/2/langref/flash/display/Sprite.html#startDrag()):
lockCenter:Boolean (default = false) — Specifies whether the draggable sprite is locked to the center of the mouse position (true), or locked to the point where the user first clicked the sprite (false).
Also if your manually setting the objects (cursor's) x and y positions, then there is no need for the "cursor.startDrag ();" line.
LittleFenris
January 2nd, 2008, 02:34 PM
That is what the second parameter for the startDrag () is (lockCenter).
From Livedocs (http://livedocs.adobe.com/flex/2/langref/flash/display/Sprite.html#startDrag()):
Also if your manually setting the objects (cursor's) x and y positions, then there is no need for the "cursor.startDrag ();" line.
If you put startDrag(true) it still looks to the registration point of the cursor movieclip for where the cursor actually points and interacts with buttons and such.
If you do startDrag(false) then the spot where your cursor actually triggers buttons depends on where you had the cursor movieclip on the stage when the swf is compiled.
I've been playing around with this with a quick button I made and its really buggy. The button shows its over and out states sorta randomly when you roll over the button with the "custom cursor". The button acts fine w/o the custom cursor but with the cursor movieclip showing the button acts erratic. Is the cursor movieclip getting in the way of the button functionality?
I figured out how to stop the erratic button behavior with the custom cursor. Instead of the cursor movieclip already being on stage I added it from the library and that seems to stop the weird behaviors when interacting with buttons and such. "Cursor" is what I put as the class name in the linkage properties for the cursor movieclip.
var cursor:Cursor = new Cursor();
cursor.x = mouseX;
cursor.y = mouseY;
addChild(cursor);
Mouse.hide();
cursor.startDrag();
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.