ActionScript 3.0 :: Disable MouseEvents For Certain Objects?
Mar 23, 2009
I have a flash AS3 doc and some classes that I created. On one of the classes, it creats a sprite that may have a scroll bar, (which i also made - not the UIScrollBar component). This uses the MOUSE_DOWN event for scrolling.
On some other classes, there are some objects that use the MOUSE_OVER event.
The problem I have, is that if you click and hold the mouse button to begin scrolling, then move the cursor outside of this Movie Clip onto another with the MOUSE_OVER event, then that event will still fire. Also, if you MOUSE_UP and you are outside the Movie Clip (with the scrollbar) then the MOUSE_UP event does NOT fire, and the scrolling is "locked" on until you click inside that moive clip.
How can I prevent mouse events on objects from firing when the MOUSE_DOWN event is firing for scrolling? Also, how can I make it so the MOUSE_UP event will fire no matter where on the stage the mouse cursor is.
I can't seem to figure it out because the MOUSE_DOWN, MOUSE_UP and MOUSE_OVER for the different objects have the eventListeners created in different classes.
As an AS3 beginner, I'm trying to translate an old AS2 trick into AS3. I want to disable then re-enable any kind of interactivity with all the display objects on the stage, at once. For example while waiting for external assets to load or after a user clicks on a menu item.
This what I used to do with AS2 : protect_mc.onRelease = function():Void {}; protect_mc.enabled = false; protect_mc._alpha = 0; protect_mc._visible = false; Then switching protect_mc._visible to true or false. (protect_mc being an empty movie clip with the stage's height and width, at the highest depth)
My first idea is registering a listener with the Stage for the capture phase of MouseEvent.CLICK that stops all input events propagation (mouse, focus, text...), when a "lock" static variable is set to true or does nothing otherwise. Second idea is using a Custom Event...
Im new to AS3, and i have to use it for my current project. I have used the AS2 Transform tool extensively, but needless to say, the AS3 version works entirely differently.[code]...
i have password protected SWF files. Afters entering right password is stored into readers computer SO with UID identifier. I need restrict numbers of computers, where can be used one ID (as to reader can't give his ID to unauthorized readers. This method is ok by the time, when authorized reader give his SO to the unauthorized.Existing some method, how i can find how much computers have stored SO with the same UID? Or how i can block using SO on unauthorized computer?
Working with senocular Transform Tool - How to remove/disable tool for objects Im new to AS3, and i have to use it for my current project. I have used the AS2 Transform tool extensively, but needless to say, the AS3 version works entirely differently. The way i understand it, the tool applies to and every Sprite , movieclip on stage
I now have working code that creates a mask of about 2,700 children on a 650 by 450 image using a container to hold all the children's MCs.
Can anyone provide any help as to how I can access these children at once with a MouseEvent so that I could for instance change the alpha value of a child shape when the user rolls over it with their mouse.
I have some code that draws a line that follows the mouse and fades away over time, until now it was in the main file of my program but i want to make a class out of it for later use in other programs. I edited the code into a singleton MouseHandler class with one function that registers the mouse up and down events; with trace and 'hasEventListener' I found out that the events are registered but nothing happens when I press my mouse buttons.
Here is the class package { import adobe.utils.ProductManager; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.display.Sprite; [Code] .....
In my main class I just use MouseHandler.getInstance().startListening(this);
I have a special canvas class covering my entire stage, and a bunch of Sprite hotspots on the layer below. If I put the hotspots on the same layer as my canvas, the canvas does not register MOUSE_DOWN events if my mouse is inside one of the hotspots, since the hotspots are targeted instead. However, if I keep the hotspots on the lower layer, the canvas handles all the MouseEvents. Is there any way to make MouseEvents target more than one thing, so that both the canvas and hotspots respond to MouseEvents? (The canvas is a bitmap drawing class and the hotspots are supposed to trigger when the cursor touches them or clicks on them.)
I made a spiral in pv3d using a mc for material and added a listener for the mouse events.Now the problem is that when i rollover my mc the rollover tween start and directly start the roll out tween.The clickhandler is rendered useless.So before adding tweenlite to the class everything works fine?
When I have a Label on a Sprite for example, it doesn't respond to MouseEvents, or at least not correctly. For example, if I set buttonMode = true on the Sprite, the label won't have the clicking cursor. Is there a work around for this? Other than stacking another Sprite on top of it which seems very inefficient.
I was just wondering if there are any problems that could arise from passing MouseEvents of different types (i.e. MouseEvent.CLICK or MouseEvent.MOUSE_DOWN) at different times to the same function? I've already built my project, and it seems to function fine, I just want to make sure that I'm not setting myself up for some problems in the future. I understand it's probably not the "cleanest" or "best practice" to construct my project in this manner, but if it works...
A simplified example: PHP Code: // This is the function that I want to call from varying places with different MouseEvents and triggered by different event listeners function myFunctionA(evt:MouseEvent):void{ [Code] .....
Actually, in writing that, I may have answered my own question, because it seems that myFunctionA is simply expecting a MouseEvent... regardless if that event is CLICK or MOUSE_DOWN or MOUSE_UP event, right? Now, a MouseEvent.CLICK may have different properties than a MouseEvent.MOUSE_UP that I can access within myFunctionA; however, that shouldn't matter to the function, or is my thinking flawed?
been working for while in an AS3 project. realize now that any InteractiveObject on key tab focus doesnt invoke its MouseEvents, MOUSE_OVER AND MOUSE_OUT listeners. I know this is not suppose to happen automatically but in AS2 I would define at beginning of project a prototype action on MovieClip that it should rollover when on setFocus.Is there a way for me to set on the entire project that any InteractiveObject on key tab focus should invoke its MouseEvents if they exist?
I would like to know how to compose a click mouseevent of different objects in one listener, if ever that's possible.What I wanted to do is make this listener universal for all the button clicks like:
stage.addEventListener(MouseEvent.CLICK,clicker); function clicker (e:MouseEvent):void{ if (frame2_btn is clicked){ gotoAndPlay(3);
I'm using a ScrollPane to contain a listing of sentences that sometimes have links in them. When the user clicks the links it does something.
When I don't put these inside of the ScrollPane the links work. When I put them in there apparently the ScrollPane is blocking the MouseEvents, or maybe it doesnt really register them since I don't know how setting the content works (if it adds the content as a child or draws it as a Bitmap inside or what)
I'm trying to rework an example found in the AS3 PDF manual, to work without the initial mouse click, but I'm not sure what to do.
The example is as follows (found on page 304 if you have the PDF) - I have changed it to move instead of fade, but didn't change the name of the function:
I made a very simple scrollBar using the MouseEvent.MOUSE_DOWN event, which works fine. The problem is I have a few other obejcts that have MouseEvent.Mouse_OVER events, and so if you are dragging the scroll bar, and then move it over one of the objects, the Mouse_OVER event fires. Is there a way to prevent this?
I had a dynamically created list of MCs that each had rollover states as well as click actions. Everything was working fine...
...Since the list was longer than the bounding areas that I wanted it constrained to, I added a mask to the container MC that was holding the dynamically created list (using AS3 - not through right-clicking the Layers). Now the list is still being generated, but the CLICK and MOUSE_OVER events are not working.
I'm building an air app which will run on iPads. For the touch interaction I'm using just MouseEvents handlers (MOUSE_DOWN, MOUSE_MOVE, MOUSE_OUT, MOUSE_UP) because my app don't need multitouch, now I'm wondering if there is any difference in execution speed, should I use the equivalent touch events or the mouse events are faster?
I am plain stumped. I am working in F8/as2.0.I have a class that extends the MovieClip class. I have a blank_mc in the library that is linked to the class. Here is the constructor:
ActionScript Code: public function MyMC (target_mc:MovieClip){ var _mc:MovieClip = this; _mc = target_mc.attachMovie (.....); }
That works all fine and dandy. Where I am having issues is basically I have properties x, y that DON't overwrite the _mc's _x & _y props. Instead, the use getter & setters that take values and then calculate the needed number to set the actuall _mc._x, _y props. This doesn't seem to work at all and i don't know why. Here is the code:
[Code]
So I got this to work by NOT extending the MC. Instead I have a variable ref to a _mc prop in the class.However I am unable to set event functions to it even if I make some ref to the _mc prop. Is there a good way of approaching this by say a decorator pattern?
I have a panel as a sprite containing a gallery of images (only 8 images at the moment!). Each image has mouse rollOver and mouse click event listeners, which work fine initially. Problem is, when I hide the panel using visible = false, then show it again, the mouseEvents aren't firing on the gallery iimages.
Strangely, the same thing happens if instead of using visible true/false, I move the panel off stage and then back on again.
I've got 3 coloured balls and 3 zones which any of the balls can be dropped in. The idea is that once a ball is placed in a zone, it stays in that zone and no other ball can be added to that zone until the current ball is removed.
I've got to a point so that any ball can be placed in any zone. However, the problem is there seems to be some hierarchy with regards to the balls. ball0_mc seems to be the chief ball, and will replace any of the other two balls if there placed in a zone, instead of snapping back to it's original position because the zone is full. ball0_mc also can't be replaced by any of the other balls if its placed in a zone. ball1_mc is the next one down the line and when in a zone, can be replaced by ball0_mc if its dragged over it, but it cannot be replaced by the third and final ball2_mc. ball2_mc seems to be the runt of the pack and can be replaced by either of the two other balls when its in a zone and cannot replace any of the other balls when they're in a zone.
Hope you're still with me?! So, what I'd like to do is make it so each ball is equal, so when any ball is placed in a zone, it can't be replaced with another ball until the current ball has been removed...and they live happily ever after in the land of ballshire.
Here's my code. I've created two classes, one linked to the movie clip balls called 'Ball', and another called 'EgoGame' which is being used as the document class for the main .fla file.
The problem I'm facing is not with loading the content of the Movie Clip, (though I might experience issues with that later when I try to load dynamic swfs) because as for now I just have placeholders on frames.
What I want to know is why my red squares on the left navigation keep getting smaller as I repeat the MouseOver and MouseOut events. It doesn't seem that these squares follow the logic of the code the way I have written it. Some of the code was generated from a previous post with the help of contributors.
Now I have again hit a slight snag with coding the math properly. Initially when I tested the code it worked fine without any "shrinking" going on. However, now with more code added the red navigation squares don't bounce back to their original states, they just keep getting smaller.
I am trying to do panning of a movieclip I have two movieclips on stage. canvasPanel_mc and mask_mc. The former is the maskee for the mask (mask_mc). Inside mask_mc there is a movieclip dragCanvas_mc. The alpha of dragCanvas_mc is set to zero. This is code that I am using:
I don't know why but I thought that this was pretty swinteresting, that even if an objects' parent has mouseChildren=false; you can still have it dispatch and receive mouse events.
Code: var a:Sprite = new Sprite; a.graphics.beginFill(0xFF0000); a.graphics.drawRect(0,0,50,50);[code].....