AS3 MouseMove laggy issue with transparency on FireFox - actionscript-3

I'm using a Custom Cursor when hovering a movieclip by using MOUSE_MOVE
spectrum.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent):void{
Mouse.hide();
mouseCursor.visible = true;
mouseCursor.startDrag(true);
mouseCursor.mouseEnabled = false;
mouseCursor.mouseChildren = false;
e.updateAfterEvent();
});
when I set
wmode='transparent'
MOUSE_MOVE still works smoothly on Chrome and IE, but on FireFox the cursor becomes super laggy when hovering the MovieClip..any ideas why?
I also tried EnterFRAME with the Custom Cursor, but it's also laggy..
If I set wmode ='window' MOUSE_MOVE works again, and not laggy anymore..
Why does mousemove become so laggy when setting wmode='transparent' on FireFox ? Can anyone help me ?

I'm not sure that your problem is wmode = transparent!
Rather than constantly starting the drag, you should rather either just start it once and then stop it when you dont need it anymore
or
just set the cursors position rather than using drag.
spectrum.addEventListener(MouseEvent.MOUSE_MOVE,function(e:MouseEvent):void{
Mouse.hide();
mouseCursor.visible = true;
mouseCursor.mouseEnabled = false;
mouseCursor.mouseChildren = false;
mouseCursor.x = mouseX;
mouseCursor.y = mouseY;
});

Related

Actionscript: BlitMask stopping mouse event listeners from working, how to fix?

I have a button class which contains event listeners to trigger an animation of the button on click.
I used many instances of this class to form a list which the user can scroll through. I have implemented BlitMask, this works, however the mouse event listeners in the button class no longer work. This code
_blit = new BlitMask(_mc, _obounds.x, _bounds.y, _bounds.width, _bounds.height, false);
Is what stops the button class.
How can I get the behaviour pre blitmark?
My code which creates the bottom is
var tf:TextField = new TextField(text);
tf.x = 70;
tf.y = 20;
_btn.addChild(tf);
_btn.addEventListener(MouseEvent.CLICK, click);
click is never called.
The blitmask causes the movieclip to be nothing more than an image of clip.
bitmapMode must be set to false to correct this.
_blitMask.bitmapMode = false;
EDIT: To expand on a further issue that implementing this solution causes, turning bitmapMode on only when needed causes the bitmap to not reflect changes in the classes that changed while bitmapMode was off. So you must set
_blitMask.update(null, true);
To force a full update when you use
_blitMask.bitmapMode = true;

AS3: Sprite does not dispatch mouse event

I am new to as3. I have developed a small application which in as3. But issue is the sprite created does not dispatch any mouse events [ eg: click ]. Please can anyone guide me and throw some comment
.... private var progressBarHolder:Sprite = new Sprite();
progressBarHolder.graphics.clear();
progressBarHolder.graphics.beginFill(0xeaeaea);
progressBarHolder.alpha = 0.5;
progressBarHolder.graphics.drawRoundRect(0, 0, 80, 25, 0,0);
//progressBarHolder.graphics.endFill();
progressBarHolder.width = progressBarWidth;
progressBarHolder.height = 24;
progressBarHolder.x = 48;
progressBarHolder.y = _videoModule.getHeight() - 48;
progressBarHolder.buttonMode = true;
progressBarHolder.addEventListener(MouseEvent.CLICK, progressBarHolderClick);
_overlay.addChild(progressBarHolder);
.....
Thanks!
Code looks ok, possible problems:
width and height of your sprite are not zero (progressBarWidth != 0)
mouse is enabled on parent (_overlay), to make sure use -
progressBarHolder.mouseEnabled = true;
make sure there is nothing above progressBarHolder on the Z index that is blocking the click from the sprite.
Your code is correct. Look up on _overlay or progressBarHolderClick listener. Also It's can happens if property mouseChildren of _overlay or other parent set as false.
Show more code if you still can't find solution.

Why is my custom cursor slow?

I just made a custom cursor using this code:
function initializeGame():void
{
cursor = new Cursor();
addChild(cursor);
cursor.enabled = false;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
}
function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}
initializeGame();
The anchor point is registered in the top left hand corner. The problem that I am having is that the cursor is very laggy. My custom cursor contains no animation, it is just a cross hair. Is there any way to make it move faster like a regular cursor?
There is. You should update the screen (make a redraw) upon every mouse move. Add this to your mouse move listener:
event.updateAfterEvent();
There is a much better way to use custom cursors, check this tutorial -
Working with native mouse cursors in Flash Player 10.2
try using Event.ENTER_FRAME instead of MouseEvent.MOUSE_MOVE if possible. I did it and it made speed much better

AS3 collision dectection mouse movement

I am making a game which uses collision detection with the mouse.
The player is a custom mouse cursor when the mouse collies with an object the mouse is moved to the coordinates X0,Y0. The code I have used to achieve this is below. However when the mouse is moved to X0,Y0 after a collision when the mouse is moved it starts back where the collision took place rather than moving from the top of the screen.
import flash.events.Event;
var cursor:MovieClip;
function initializeMovie ():void {
cursor = new Cursor();
addChild (cursor);
cursor.enabled = false;
Mouse.hide ();
stage.addEventListener (MouseEvent.MOUSE_MOVE, dragCursor);
}
function dragCursor (event:MouseEvent):void{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}
initializeMovie ();
this.addEventListener( Event.ENTER_FRAME, handleCollision)
function handleCollision( e:Event ):void{
if(cursor.hitTestObject( wall )){
cursor.x = 0
cursor.y = 0
}
}
Create a button at the 0, 0 coord that is required to click to continue again. Then your user will have to move the mouse to to that spot where you can continue to have the custom cursor track your mouse.
When you reset the position of cursor object you aren't moving the actual mouse position, I don't believe you can actual do what you're trying to (that is write to the mouse position to move the users cursor, I believe this would require system specific code, like C# or I believe Objective C and Cocoa or Carbon on the Mac side).
http://www.kirupa.com/forum/showthread.php?354641-Possible-to-set-mouse-position-in-flash
Here's a way you would do it on Mac apparently
https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html#//apple_ref/c/func/CGWarpMouseCursorPosition
And a way on Windows
Set Mouseposition in WPF
And a way on Linux (Although this only has AIR support up to 2.6)
How to set the mouse position under X11 (linux desktop)?
So if you implemented both of those solutions and are packaging as an AIR app you could make this work, but otherwise I'm pretty sure it's impossible.

About flickering mouse custom cursor in ActionScrip3

I have a problem with flickering mouse custom cursor.
I have a timeline which is my main clip and I want to show a pencil like cursor when I am over the timeline movie clip. I am using standard Mouse events, MOUSE_OVER and MOUE_OUT, MOUSE_MOVE. Also I use Mouse.hide()/show() functions to show and hide the mouse. Also the same principal or the pencil movie clip which I show and Hide.
On MOUSE_MOVE is set the coordinates of the pencil movieclip to be those on the Mouse cursor.
How ever I get a flickering of the mouse and the pencil movieclip while above the timeline movieclip. So they change from one to another all the time without stopping i.e filckering.
Any idea what is my problem?
(I am not using any code for this in enter_frame function)
public function setMouseOver(e:MouseEvent):void {////on MOUSE_OVER
pencilCursor.visible = true;
Mouse.hide();
mouseOverCont = true;
}
public function unsetMouseOver(e:MouseEvent):void {////on MOUSE_OUT
pencilCursor.visible = false;
Mouse.show();
mouseOverCont = false;
}
public function showHoverBaloon(e:MouseEvent):void {////on MOUSE_MOVE
pencilCursor.x = stage.mouseX;
pencilCursor.y = stage.mouseY;
}
Sounds like "something" gets in the way of the mouse cursor and triggers OVER and OUT events.
Set mouseEnabled and mouseChildren to false on "pencilCursor".
pencilCursor.mouseEnabled = false;
pencilCursor.mouseChildren = false;