ActionScript 3.0 :: Difference Between "$event:MouseEvent" And "e:MouseEvent"?
Jul 28, 2011What's difference between "$event:MouseEvent" and "e:MouseEvent". What do they do?
View 4 RepliesWhat's difference between "$event:MouseEvent" and "e:MouseEvent". What do they do?
View 4 RepliesWhat is the difference between MouseEvent.MOUSE_UP and MouseEvent.CLICK? Why should I use one of these over the other?
Code:myButton_btn.addEventListener(MouseEvent.MOUSE_UP, fNavigate, false, 0, true);
myButton_btn.addEventListener(MouseEvent.CLICK, fNavigate, false, 0, true);
I have several stage event handlers to enable mouseovers over several dynamically generated moviecilps on the stage that then change their alpha to indicate the mouse is over that particular mc... fairly trivial (mcOver handler). Additionally, I also want to know what MC is clicked, so I update a public variable (public var activemc:Number) with the ID of the dynamic movieclip when the mouse is over it (using a hitTest to check, which is why the EventListener is added to stage and not to the MC), which is checked in the mcClicked handler:This is in the constructor:
//stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);
//stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mcOver);[code]....
However, the mouseover behaviour (alpha 0 when over, alpha 1 when out) stops working as soon as I click on any movieclip on the stage, and the mcClicked ID checking (below) stops working completely. I don't know if this is to do with focus:
private function mcClicked(event:MouseEvent):void {
myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID
}
I then tried adding the event handler for the stage mouse_move again and this gets the mouseover working again but only for 1 more click, after which it stops again:
private function mcClicked(event:MouseEvent):void {
myTextField.text = String(activemc); // activemc is a public var:Number with the movieclip //ID
stage.addEventListener(MouseEvent.MOUSE_MOVE, mcOver);
What does "$" means in actionscript 3? What's the difference between "$event:MouseEvent" and "event=MouseEvent"?
View 2 RepliesI have a MovieClip (call it base_mc) which is under a bunch of other MovieClips (call them subclips). The MovieClips on top are all mouseEnabled with MOUSE_OVER, CLICK, etc, event handlers. I want to capture the event of MOUSE_OVER (or ROLL_OVER) on the base_mc as well. Any time I am over one of the subclips I am also over the base_mc clip. How can I capture this event?
View 2 RepliesI'd like to know what is the difference between MouseEvent.CLICK & MouseEvent.MOUSE_DOWN. Because when i use MouseEvent.MOUSE_DOWN for a button to set full-screen view its doesn't work, instead of this MouseEvent.CLICK works. So what was the reason.
View 3 RepliesI'm making a button for the first time, and I wanted to use a full click to drive it. However, when I use addEventListener(MouseEvent.CLICK, onClickHandler); nothing happens when I click on it. When I use (with the rest of the code being identical) addEventListener(MouseEvent. MOUSE_ down, onClickHandler); it works like a charm.
View 6 RepliesI have a MOUSE_DOWN handler that creates a CLICK event listener on a child object. Naturally, as soon as you release the mouse button, if you happen to be over the child object, the CLICK event fires.I was disappointed to discover that event.stopImmediatePropagation doesn't interrupt the CLICK event from registering the MOUSE_DOWN as part of its detection cycle. It makes sense that it doesn't but still... disappointing.A MouseEvent.CLICK consists of detecting a MOUSE_DOWN on the object and then if it's followed by a MOUSE_UP without leaving the object, he event fires. I had hoped that by cancelling the MOUSE_DOWN event, it would clear that out of the CLICK buffer, but no such potatoes, alas.This could all be handled with a flag and a couple more MOUSE_UP and MOUSE_DOWN handlers, but dang, smacks of effort
View 2 RepliesI have the following:
rwBtn.addEventListener(MouseEvent.MOUSE_OVER, audioOver);
function audioOver(e:MouseEvent):void
{
var thisClip:MovieClip = e.relatedObject;
thisClip.alpha = 0;
}
I would like to change the alpha of the clip that is being rolled over. I don't know how to target the clip that is being rolled over. How do I do that?
in actionscript 2.0, one could call a mouseEvent function without actually having that event. For instance:
btn1.onRollOut = function(){
this. gotoAndPlay("out");
}
[code]......
I hv make 4 movieclips and i wanna add mouse event but it is showing error on MouseEvent function, and the error is. 1046: Type was not found or was not a compile-time constant: MouseEvent.
[Code]...
i've created a bitmap with data and placed it into a sprite so to receive mouse events. however, i'm struggling with reading the BitmapData within the sprite.
[Code]...
Trying to use the MouseEvent.Mouse_Move event. Simply, there's one 300 x 20 line which the event is assigned and another line (100x20) is top of the first line. But if mouse moves over the second line, the event is not working... The same event could be assigned on the second line but it seems a bit waste and I'm sure there must be a way to trigger the event through the other object.
View 2 Repliesin actionscript 2.0, one could call a mouseEvent function without actually having that event. For instance:
[Code]...
In this example, of course, rollOutHandler only does one thing, but this function could contain lots and lots of code, and I would not want to repeat all of it again inside the clickHandler function.
This is NOT duplicate of my earlier post (its is slightly different)But this is similar issue with similar error but its not the same error The error I am getting now is below while dispatching the custom event from my custom component
TypeError: Error #1034: Type Coercion failed: cannot convert events::MapEvent@a74ab51 to flash.events.MouseEvent.
dispatchEvent(new MapEvent(MapEvent.CLICKED_ON_MAP));
Note: The error in my earlier post is giving below error message
Type Coercion failed: cannot convert flash.events::Event@81ecb79 to com.events.ShopEvent
The difference here are two things, the earlier error is while converting flash event to custom event and now this one is while converting custom event to flash event and secondly, I have no clue why it is trying to convert to the mouseevent where I am just dispatching my custom event with proper listeners.
This is my custome event
package events
{
import flash.events.Event;
import ui.map.MapElement;
[code]...
iam making a game and i almost finish except one error i couln.t get it
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
[code]....
I linked a button to a .php file, but now i have the problen that if I try to do it again, I get an error : 1021 Duplicate function definition
ActionScript Code:
myButton.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void
[code]......
I want to simplify some event handling of an flash app (if that is possible).. so i thought to extend MouseEvent in some way to do it.What i need is OVER, OUT and CLICK callbacks with an extra parameter (an object)... or something like that..I tried:
Code:
package com.ui{
import flash.events.MouseEvent;
[code].....
This is what I used to have in AS2
Code:
on (rollOver) {
gotoAndPlay(2);
[code].....
I've created a function called dragItem() that I call with the MOUSE_DOWN event. I've got it working....kind of. I can access the function when the mouse is clicked and I can even get the name of the instance when the mouse is down. I'm trying to use the same logic to get the single object to allow a drag. see my code below...
function dragItem(event:MouseEvent):void { var instName:String = event.target.name; trace(instName); trace(event.target.width); event.target.startDrag(); event.target.removeEventListener(MouseEvent.MOUSE_DOWN,dropItem); event.target.addEventListener(MouseEvent.MOUSE_UP,dropItem); }
I get this error when I try to drag the item...ReferenceError: Error #1069: Property startDrag not found on flash.display.Loader and there is no default value. at Main/::dragItem()
but1.addEventListener (MouseEvent.CLICK,play1) ;
function play1 (event:MouseEvent) :void{
gotoAndStop("Wales 1") ;
}
This is my code but the MouseEvent is not recognised
I am develop on Air for iPad app, just wonder is TouchEvent more efficient or MouseEevent is doing fine. i am talking about performance wise, things like doing drag and drop and ect...
View 1 RepliesI dynamically create images in a loop (flash builder 4.5) and when I set mouse click event, I'm using this:
image.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void{fromThumbnail(e,i)});
to pass i. However, when I click on any image, the function thumbnail prints the last i.
Is there solution for this problem?
Why is working properly in Internet Explorer, but not in FireFox 3.0
View 0 RepliesI have two sprites A and B, both are irreuglar drawn shapes (both with a transparent fill) that overlap certain points. The current result is B on top (though which is on top is not really relevant, as the same problem will exist if A is on top). They are both children of the same UIComponent.
Both are listening for the MouseEvent.MOUSE_MOVE event. It is to occur when a corner on either shape is passed over by the mouse. Though, when the mouse moves over the corner of A and this corner is behind B the MouseEvent is never raised.From my investigation I've found when i turn the fill off on the sprites and just draw the outline of the shape the mouse event will raise, but this is not what is wanted. how can I get *both* the objects listening and responding even when the corners of one is overlapping the other?
I've googled around and seen this topic at a million places but I just don't get the solution![url]...
Like in the image above. My red movieclip is dragable when mouse_down and dropped when mouse_up. At the same time I want the underlying Blue MC to get it's mouseEvents but if the Red MC is overlapping it, it won't react. What do I do to make both active?
Do you have to perform some kind of VooDoo magic to get MouseEvent.DOUBLE_CLICK to workhere's my code:
Code:
import flash.events.*;
box_mc.addEventListener(MouseEvent.DOUBLE_CLICK, openFolder);
[code].....
I'm making a game where you keep a ball in the air by clicking on it, but the mouseevent doesn't always register.
PHP Code:
var debug:Sprite = new Sprite();
var sine:Number = 0;
var cosine:Number = 0;
var hypotenuse:Number = 0;
[code]....
The only thing I have on the stage/library is a circle named 'ball_mc' width origin in the center.
I'm building a grammar excercise where I've got 24 drag'n'drop cards (movieClips), that I can drop into two 'slots' or dropTargets. Each card has its corresponding card, and when the right cards are dropped in the dropTargets, they get a 'well done' message, and a button appears so the user can go on to matching the remaining cards. When the button is clicked, I want the dropped cards to simply disappear.
View 7 RepliesHow can I trigger a MouseEvent from a nested MC?
Basically I have a Sprite that contains a Shape. I'd like that Shape to trigger the listener I've attached to it however, Flash just thinks the container Sprite is being clicked every time.