ActionScript 3 :: MovieClip HitTest - Fire Event When Object Clicked By Mouse

Oct 25, 2011

I have a MovieClip. It represents animation of jumping monster. For clearness, let's pretend there are only 2 frames: the first one occupies top left rectangle (x = 0, y = 0, w = 70, h = 70) and the second one occupies (x = 100, y = 0, w = 70, h = 70). So monster jumps from left to the right. And position of MovieClip itself is constantly = (0, 0).
I'd like to fire some event when monster is clicked by mouse.

For some reason, I have stage mouse listener, not monster mouse listener. I wrote this code:
stage.addEventListener(MouseEvent.CLICK, onClick);
private final function onClick(e:MouseEvent):void {
const clickPos:Point = new Point(e.stageX, e.stageY);
// having monster:MovieClip, how do I check hitting it?
[Code] .....

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Function Not Fire Unless Mouse Clicked?

Jul 9, 2011

My document class is Controller It's constructor addChilds an instance of MenuScreen

MenuScreen has 1 button called 'gallery'. Clicking on it removes the MenuScreen from the document class and adds galleryScreen to the Document class.

After the galleryScreen becomes a child of the document class I add a keyevent listener like so:

ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
Here's a snippet of keyDownHandler:
ActionScript Code:
public function keyDownHandler(event:KeyboardEvent):void{

[Code]....

The Problem is: 1) I'm pressing LEFT arrow key like mad and nothing happens UNTIL I left click anywhere on the screen, THEN keyDownHandler works.

View 7 Replies

Actionscript 3 :: Click Event Fire When Checkbox In ItemRenderer Is Clicked

Mar 8, 2012

I have an itemRenderer custom component inline of my DataGrid component. I need to have an event fire in the containing class (at the same level as the DataGrid) when the checkbox is checked or unchecked (in the itemRenderer component). How would I do this?

[Code]....

View 1 Replies

Flex :: Flext Text Link Event Doesn't Fire Until Clicked It Twice?

Jun 22, 2010

I've got a canvas within which I have a list. The renderer for this list calls upon a "Text" field, with the "link" element of this field set to a function. The "htmlText" of the field is set dynamically to a mixture of words and links. Basically the function checks to see which tag within the htmlText has been clicked and performs an event accordingly.However, you have to click the link twice for anything to happen. Whilst debugging the code I noticed that the function referenced by the "link" element isn't actually even called until the 2nd click.

<mx:Text
id="textCanvas"
width="100%"
color="0x323232"
selectable="true"
link="{lbl_link(event)}" />

I've changed the code a little bit to make it easier to follow, but the ActionScript is roughly as follows:

private function creationComplete():void {
textCanvas.htmlText = "Hello <a href='event:username'>" + username + "</a>";
}

[code]....

View 1 Replies

ActionScript 3.0 :: Moving Mouse Causes To Fire KEY_UP Event

Feb 28, 2009

I'm trying to make as3 application which uses custom mouse pointer while pressing spacebar on my keyboard. Everything works fine when I don't move my mouse but when I do the KEY_UP event is dispatched to my listener almost immediately (and this is while I'm still pressing my key down). Below is simple main class which used to test this behaviour:

[Code]...

View 14 Replies

ActionScript 3.0 :: Mouse Out Event Doesn't Fire Everytime

Feb 10, 2012

I use movie clip as a button. Inside movie clip there are two movie clip, each one for a separated condition. On mouse over it goes on white one.On mouse out it returns on blue one.If it is pressed it stays white.Mouse out doesn't fire every time. It is placed on the white movie clip. It fires in 90 percent.Movie clip contains shape and two images inside.

View 5 Replies

Javascript :: Jquery - Mousemove Event Does Not Fire When Mouse Is Over Flash

Jan 25, 2012

I'm using Javascript's mouse event to pass information about mouse position to flash and show the specific animation frame depending on mouse position.

The problem is, when mouse is over flash object, it doesn't fire javascript event anymore. I've tested it on Chrome and it seems to be working, but Firefox doesn't want to cooperate.

My flash object is located in the middle of website and has transparent background. It has to stay this way. Also, I'd rather not move the action to the ActionScript for two reasons:

Website's width is not constant (different browsers for example) so I'd have to push viewport's width to the flash too, which will complicate the script, also mouseenter events etc. I don't know AS very well.

The code: (I'm using jQuery here because it's also used somewhere else on the page, previous mockup used plain JS)

function viewport()
{
var e = window

[Code]......

View 1 Replies

ActionScript 2.0 :: When Mouse Is Clicked, Detect Which Movieclip Is Clicked

Sep 9, 2009

I have parent movieclip and in that many different children movieclips

What i want to do is when i CLICK, i want to detect which movieclip it has clicked and call corresponding function (defined by onpress event) of that movieclip.

View 6 Replies

ActionScript 3.0 :: Catch Mouse Event On Movieclip While Dragging Object?

Jun 10, 2011

I have a situation where I am allowing the user to drag a movieclip by means of startDrag and setting a rectangle. However while they are dragging this about, I want to register when the mouse moves over another object, however I can't seem to get this to work while they are dragging the object.

View 2 Replies

Actionscript 3 :: Flex 4 - Event Doesn't Fire When The User Scrolls With A Mouse Wheel Or Arrow Keys

Dec 8, 2010

Within my application I'm using a Scroller component. I can't seem to figure out which event I should set up a listener on in order to know when content is scrolled. I tried Event.CHANGE on Scroller.verticalScrollBar property but apparently that event doesn't fire when the user scrolls with a mouse wheel or arrow keys.

View 1 Replies

ActionScript 3.0 :: Event When Mouse Is Clicked Outside Of Swf?

Jan 23, 2010

I'm working on [URL] and I am using a small swf over the milk carton on the left. I use it to make it look like text being entered is on the milk carton. So its just a textfield and a button.

When the user clicks in the text box it clears and allows typing. This is good. This is the part I'm stuck on: If the user changes their mind about typing and clicks somewhere else on the screen (outside of the swf) I want the example text to return and the text cursor to stop flashing.

View 2 Replies

ActionScript 2.0 :: HitTest Of Moving Object With Mouse?

Dec 17, 2009

My first post in Actionscript.org. but I'm a long time visitor / fan. I'm moving a object with mouse but using some easing values. means it will follow the mouse slower.

Here is the file.[URL].. How can i check hitTest in this situation. even if i do it normally...the object is passing the collision object simply before stopping..because its being moved with mouse..

[Code]...

View 0 Replies

Actionscript 3 :: Possible To Trigger Click Event Only / When Mouse Is Clicked On Image Part?

Mar 3, 2012

I have a problem and I have potential solution. But I wanted to confirm if there is an easy and simple way to solve my problem.App type:Isometric Game.Problem statement:I am loading images in my flash app and have mouse events attached to them.The images I load are prop images like vehicles, trees, buildings etc., and all of them are transparent.Example: Red ball asset (please ignore the yellow background which I applied to describe the problem)If I click on the actual image area (colored in red), then every thing works perfect.I don't want to trigger mouseevent when I click on empty image part (or transparent area, which I have shown in yellow color)There is one way I know by creating masks in flash. I don't want to do it unless that is the final option left because I load image assets instead of flash assets and I don't want to create a new mask asset for all the assets.There is another method I was going to adopt by using getPixel method of Bitmap.

But there is another problem with this method.I might be able to ignore the click event when I click on the empty part of the asset but if there is some other asset is behind the image in the same location, then I need to process the click event for the occluded image.Well, thinking of solution to this problem takes me to the getObjectsUnderPoint where I can scan the occluded assets

View 2 Replies

ActionScript 2.0 :: Detect OnRollOut Event When Left Mouse Button Is Clicked?

Apr 12, 2011

have one mc called mc1, and when the mouse cursor is over it, mc2 is sent to a certain frame and the _alpha set to 0. The problem I have is that when the user continued with the onPress (pressing the left mouse button) after the cursor goes outside of that mc1, mc2 does not become invisible and what I need is to do that, when the user goes out with the cursor of the mc1, the mc2 becomes invisible even if the left button of the mouse is pressed. And now don't detect the onRollOut if the button of the mouse is pressed.

View 1 Replies

ActionScript 3.0 :: Reference A Clicked Object From An Event?

Feb 22, 2009

So ive made the switch from AS2.0 to 3.0, and like many fellow casual flashers, I'm having a bit of a tough time

I understand that below, the first trace works because the mouse event comes from the clicked object, and that the second produces an error because the ENTER_FRAME event is attached to the stage, so e.target is the stage. i realise i can attach the listener to the obj, but i need it on the stage for what im doing

How can i reference the clicked object from run() ?

ActionScript Code:
obj.addEventListener( MouseEvent.MOUSE_DOWN, doMouseDown );
function doMouseDown(e:MouseEvent):void {
stage.addEventListener(Event.ENTER_FRAME, run);

[Code].....

View 3 Replies

ActionScript 3.0 :: HitTest For Mouse Position Over A Bitmap Inside A MovieClip?

Dec 1, 2009

This seems like it should be simple, but... I've been trying to figure out how to do the following, and I can't seem to make it work. It all works except for the hit test part. I have a working drag and drop application. I need something different to happen when the user drops an object while the mouse x,y is, or is not over a certain (very irregularly shaped) bitmap inside a movieClip. how to do this? I have found some complicated ways to hit test between 2 bitmaps, but not 1 bitmap and mouse x,y.

View 3 Replies

ActionScript 3.0 :: Allow HitTest Of MovieClip To Hit Only One Object?

Jul 19, 2010

Is there a way that only allow hittest of a mc to hit one objects, if it hit multiple object it ignore it?

View 1 Replies

Flash :: On Mouse Click For Any Clicked Object On Stage?

Mar 9, 2011

i have mc with 10 objects instead of writting code for each i want same action prefermed on every clicked object with 1 code is there way to do it?

View 2 Replies

Flash :: Disable Mouse Click After A Object Has Been Clicked?

Jul 25, 2011

I have a flash shooter game and after a user shoots a bottle, i play the destroy animation and remove it from the screen. The problem is when the user click too fast, like superman fast it enters on the method twice, no matter what.

Here is the code:

public function bottleHasClicked(bottle : BottleBase) : void {
bottle.mouseEnabled = false;
collectedBottles++;

[Code]....

The first thing i do is to disable the object mouse, and it still happens. I only enable it when im gonna show the bottles again.

View 3 Replies

Actionscript 3 :: Detecting If You Clicked On An Object Without Pressing The Mouse Button?

Apr 29, 2011

Okay, in as3 when you click, the object on the highest layer will be clicked on. I want someone to press the space bar and have the objects on the screen to check to see if it is touching a point.So I first tried hittest...

if (this.hitTest(myPoint)){
play();
}

Now the problem was objects behind other ones were thinking they were being "clicked" on.

View 4 Replies

ActionScript 2.0 :: Replacing Object With Larger Version When Mouse Clicked

Oct 6, 2010

I am creating a fish-eat-fish movie. I created a fish (pike1) that follows the mouse. Another fish (Chub) is set to disappear when clicked. What I want to do is to have pike1 grow larger (either by just growing larger or having pike1 disappear and be replaced on mouse click by a larger pike (pike2).

View 1 Replies

ActionScript 1/2 :: Replacing An Object With A Larger Version Of It When Mouse Is Clicked On A Separate Mc?

Oct 7, 2010

I am creating a fish-eat-fish movie and I need some help. I created a fish (pike1) that follows the mouse. Another fish (Chub) is set to disappear when clicked.What I want to do (and need help with) is to have pike1 grow larger  (either by just growing larger or having pike1 disappear and be replaced on mouse click by a larger pike (pike2) when the user clicks on Chub

View 1 Replies

ActionScript 3.0 :: Mouse Event For Mouse Stand On An Object?

Feb 27, 2012

I'd like to animate a button when I put the mouse over it. I use mouse_over or roll_over events, ok. But what if I hide the button when I click it and then I show it again later without moving the mouse? The mouse stays over the button, but the button does not animate, as there is no out/over event: I have to move the mouse out and over again to see the animation.

How can I detect the mouse standing on a button without the out/over event?

View 3 Replies

Flash :: Getting JQuery Function To Fire When Video Is Clicked?

Apr 26, 2010

I've set up a function to pause the sound in an mp3 player whenever certain things are clicked on the page, using ExternalInterface, but I'm having a problem in IE.The setup is this: I have a video page that calls up a list of YouTube videos using RSS.he most recent video is displayed on the page in a div called "display". Then all the rest of the videos in the feed are displayed as thumbnails and links...If you click one of them, then the main 'display' video is replaced and it starts playing. All of that works fine.hat I want is for the mp3 player on the page to pause the music whenever a video is started.The ExternalInterface function works properly. Whenever one of the LINKS is clicked, the mp3 player stops and the video starts, etc.

The problem is that I also want it to stop when the MAIN video is clicked. Obviously, since this is an external video loaded from YouTube, I can't access the FLA to add its own ExternalAccess code.I've tried adding an ID to the video object and then using it as the selector in jQuery to call the stopMovie function...no go. I've tried adding a class to it, and then calling the stopMovie function when the class is clicked. I've tried putting the click function on the div that the video loads into...nothing works. If I remove the main video and just have an empty div, then click the div, the mp3 player stops...but if I load the video into the div and click it, nothing happens (in IE...it DOES work in FF).The Actionscript:

import flash.external.ExternalInterface;
ExternalInterface.addCallback("stopMovie", pauseSound);
function pauseSound(str:String):void {

[code].....

View 2 Replies

ActionScript 3.0 :: Apply Hittest Object / Point Condition To Only One MovieClip?

Jul 9, 2011

i'm breaking my head over something, and will be very grateful to any creative ideas:

I created kind of drag and drop game: i have cards that should be placed on squares.

in case the card touches any square, the square changes it's color. the problem occurs when the card touches 2 squares at their middle: they both change their color.

in fact, I need that only one of the square will change it's color, and it should be the square that the card touches it with "the most of him". i thought of using the hitpoint but i know it won't work, because in case the card touches both square in the middle it won't work..

View 2 Replies

ActionScript 3.0 :: Detect The Finished Event Listener And Fire Out Another Sets Of Event

Nov 17, 2011

if I have an event listerner (mouse, keyboard, enterframe,....event) that is being triggered, and when it finishes its event, something that is able to detect the finished event listener and fire out another sets of event.
 
It works more like MOTION_FINISH in TweenEvent, but it is only available for TweenEvent only, what if I want to detect a mousclick, keyboard, enterframe or even touch event?

View 3 Replies

ActionScript 1/2 :: Trigger A MouseDown() Event When Clicked On A Custom Shape Movieclip?

Oct 3, 2011

The below MouseDown() event works on for a squire area. How can trigger a MouseDown() event when clicked on a custom shape movieclip?

[Code]...

View 3 Replies

ActionScript 3.0 :: Event Listeners Only Fire Off At Event Once?

Feb 13, 2010

An odd thing is happening for me, my eventlisteners only fire off once then they seem to stop working.

This thing is a movieclip that slides up the parent movieclip and another movieclip within mc slides it down. They only work once.

ActionScript Code:
slider.up.addEventListener(MouseEvent.MOUSE_UP, activateSlider);
slider.down.addEventListener(MouseEvent.MOUSE_DOWN, activateSlider2);
var frameBoolean:Boolean = false;

[Code].....

View 9 Replies

ActionScript 3.0 :: Event Listener - When The Mouse Rollsover The Movieclip To Go To Frame 3 Of The Movieclip

Mar 4, 2009

i've not tried to do anything odd with eventListeners up until now. i have a movieclip with multiple frames that i use AS to attach a textfield to it. problem is i have a eventlistener for when the mouse rollsover the movieclip to go to frame 3 of the movieclip.

[Code]...

what's causing the textfield to suddenly take precedence and how do i stop it. when i trace the evt.target - it is my movieclip.

View 5 Replies

ActionScript 3.0 :: [object Class] Instead Of [object MovieClip] - Delete The Targets ENTER_FRAME Event?

Mar 15, 2009

When I use MouseEvent.MOUSE_OUT the target is [object MovieClip], but when I use MouseEvent.ROLL_OUT I get [object Bildspel] - and Bildspel is my class. The thing is that when I use ROLL_OUT I'm not able to delete the targets ENTER_FRAME event.

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved