ActionScript 3.0 :: .addEventListener(MouseEvent.CLICK Won't Work
Dec 15, 2009
I am trying to add a simple "getURL" type of functionality to a movieclip so that when it is clicked on, the user is taken to a url. i have tried 3 or 4 different ways to do this that all work when i test the movie clip in flash. However, when i embed the swf in a webpage, the click function does not work.I created a function:
Code:
function gotoPage(event:MouseEvent):void
{
var targetURL:URLRequest = new URLRequest('http://www.metteradvertising.com/marketing-help.html');
navigateToURL(targetURL);
}
and I'm calling it this way ("Bmeasure" is the movieclip name):
Code:
Bmeasure.addEventListener(MouseEvent.CLICK, gotoPage);
am i not able to attach "click" functionality to a movieclip?
View 10 Replies
Similar Posts:
Mar 9, 2011
got stuck on this for a while now: have this code but my mouse event is not responding:
function wrongRight(evt:MouseEvent):void
{
flap_Control.flap.mouseEnabled = flap_Control.flap.mouseChildren = false;
[code]....
View 1 Replies
May 21, 2010
in this listener, what do each of the the bolded elements do / what are they? stage.addEventListener(MouseEvent.CLICK, onClicked, false, 0, true);
View 9 Replies
Aug 27, 2009
The main AS timeline creates the enemy instance and calls them via the timer class. Inside the instance enemy movie clip there is some script to do a basic tween and there are functions to remove the enemy and to declare you've hit the enemy. The problem I'm having is when I try to call my KillEnemy function with a MouseEvent.CLICK (or MOUSE_DOWN, MOUSE_UP) event, it isn't registering, I realised this after testing the same function to listen for a MOUSE_OVER, MOUSE_OUT, it worked perfectly.
Can anyone explain why this is happening? Not just that the mouse seems to be a little delicate, even with the roll over listener called it isn't registering the event unless it hits a specific part of the movie clip enemy, which leads me to believe the movieclip is somehow built incorrectly? But even when testing the game with extreme settings (i.e. leaving the enemies on screen for a long time) the mouse clicks aren't registering still. Something is broken! Here is some of code inside the enemy movie clip, the problem lies on line 11:
[Code]...
View 6 Replies
Oct 2, 2009
In my class i've got something like this:
[Code]...
So Every time when I click left mouse button, the setClickedTrue function should be triggered. And that's what happen normally. But when I make a fast move with a mouse, and in the meantime i click left mouse button, or i make a fast move and finishing i will click left mouse button, the function is not triggering. Something like MouseEvent can't hear this Event. I'm making an avoid game, and it's very important. I'm using Timer class with delay = 30; I'm also have got 30FPS on Flash Proporties.
View 3 Replies
Nov 6, 2010
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);
View 1 Replies
Oct 21, 2010
I'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 Replies
Nov 6, 2010
I'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 Replies
Apr 7, 2009
What 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);
View 3 Replies
Aug 11, 2011
I 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 Replies
Feb 7, 2009
show a demo using Actionscript 3 where a child movieclip is added dynamically in a loop using addchild within a cotainer movieclip. Then the child movieclip has an addEventListener MouseEvent added to the child, not the container, in the code.
View 4 Replies
Dec 28, 2010
i am making drag drop game.i create some movie clips dynamic.
this is the code::
recipesArray=["Steak","Chicken Panee","Bread","Fava Beans", "Jam"];
/////Create Movieclips && set their text
[code].....
View 2 Replies
Sep 1, 2010
I've been searching for a solution for this problem for the best part of this day Here's my scenario,I have a swf of class a class i've called sceneHolder, it loads up an xml file and uses this to determine which external swfs to load up, the swfs are loaded up and into loader's then their contentLoaderInfo.content is addChild'ed to a movieclip in sceneHolder called myScene, they are then positioned and so on.
Another item loaded from the sceneHolder library is also loaded into myScene.Then, on the press of a button I call this
[Code]...
View 2 Replies
Jul 30, 2009
I have the following in a class and get an error message. CaseStudyQuiz is my constructor method. I want to detect when the mouse moves via the stage.addEventListener.
[Code]...
View 17 Replies
Jan 13, 2010
I have been working with this script for a few days now and have gotten to a near completed point, but I can't seem to script the final step. I have an xml file that is being parsed into my .fla file. There are 3 buttons which are dynamically created based on a tag called <navItem>. The function 'displayContent' should be displaying the appropriate chunk of xml in various text boxes, but instead, it only displays the last chunk (the 3rd chunk) no matter which button I click on. I have pasted my code on pastebin here:[URL]
View 13 Replies
Jul 13, 2010
I have a for loop that loads a variety of movie clips that I want to have function as buttons. From what I've read adding an event listener is the way to go but I'm not sure how in this case. I've searched online and found a few articles that come close to what I need but not quite. Can't I just tack on an event listener for a mouse click on these objects and have it run a function I have defined elsewhere?Also in said function what code would I need to use to reference the button that was just clicked, would this. work?
View 9 Replies
Nov 15, 2011
I am trying to build a simple mock-up of a product my team is designing and I can't seem to get the addEventListener to work. At the moment, my mock-up contains code that Alex Lexcuk has written that deals with the page flipping animation. I suspect that it might be interfering with the addEventListener code I have written. I have placed my addEventListener code inside the Content symbol. I have uploaded my project to the following URL:[URL]
View 6 Replies
Oct 4, 2009
I have th following code below. When the monster is clicked I would like to remove it but the MouseEvent.Click event never fires? I'm using flash cs4.
import fl.motion.Animator;import fl.motion.MotionEvent;var this_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*"> <source> [code].......
View 2 Replies
Oct 28, 2009
Is there any reason why a MouseEvent.CLICK would affect only 1 of 5 items, whereas a MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT affect 5 of 5 items when each event listener is applied exactly the same way?For some reason, of the 5 images I've imported, only the last image is able to be clicked and have click actions applied, yet it is able to receive the ROLL_OVER and ROLL_OUT messages. So that leaves me thoroughly confused.
Here is the code I'm using, I'd greatly appreciate your help ---
Code:
import XMLManager;
import caurina.transitions.Tweener;
import MakeHand;
[code]...
View 1 Replies
Oct 28, 2009
Is there any reason why a MouseEvent.CLICK would affect only 1 of 5 items, whereas a MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT affect 5 of 5 items when each event listener is applied exactly the same way? For some reason, of the 5 images I've imported, only the last image is able to be clicked and have click actions applied, yet it is able to receive the ROLL_OVER and ROLL_OUT messages. So that leaves me thoroughly confused.
[Code]....
View 6 Replies
Jan 13, 2012
I am using an event listener for both rollOut and rollOver to a button, on roll over it populates a text field, roll out clears the field, however I would like on click to populate the field and leave it persistant untill another roll over event happens, curently the roll_out event takes priority and when I move my mouse it clears the field, regardless of click.
what is the best way to cancel the roll_out event?
View 1 Replies
Jan 19, 2011
In my project I have 14 buttons which are added by adding the background image their in. So I have a var bg which i addChild(bg) thus also adding 14 buttons.
their listeners are set to Mouse.event CLICK, and they work fine unless i add a custom cursor then their dont work any more.
View 1 Replies
Mar 4, 2011
I have the following code:
import flash.events.MouseEvent;
import flash.events.Event;
var mouseWheel_mc:MouseWheel_mc = new MouseWheel_mc();
var over:Boolean=true;
addChild(mouseWheel_mc);
[Code]...
there is a MovieClip named mouseWheel_mc which is being called at runtime from the library with 30 frames in it, sequential animation frames.I would like the MouseWheel motion to play these frames forward or backward depending on which direction the mousewheel is being pulled or pushed.
Everything works just fine, but the problem is that the event won't start until you actually click in the SWF window (inside). I thought I could remedy that by using an Event.INIT or Event.ACTIVATE call but neither of those remedy the situation.
How can I get the event to fire once the SWF is in the browser without having to first click within the SWF?
View 3 Replies
Apr 11, 2010
is it not possible to have both CLICK and DOUBLE_CLICK on the same display object? i'm trying to have both for the stage where double clicking the stage adds a new object and clicking once on the stage deselects a selected object.
it appears that DOUBLE_CLICK will execute both itself as well as the first CLICK functions in the path toward DOUBLE CLICK (mouse down, mouse up, click, mouse down, mouse up, double click).in other languages i've programmed with there was a built-in timers that set the two apart. is this not available in AS3?
UPDATE:here's some code. essentially what i would like is have one or the other, not both with double click
stage.doubleClickEnabled = true;
stage.addEventListener(MouseEvent.DOUBLE_CLICK, twoClicks, false, 0, true);
stage.addEventListener(MouseEvent.CLICK, oneClick, false, 0, true);
[code]....
View 2 Replies
Feb 25, 2011
When I listen to mouse click event on the stage, it seems it's not always responding to my mouse click event. what I have is:
stage.addEventListener(MouseEvent.CLICK, Test);
function Test(event:MouseEvent):void
{
trace("test");
}
I usually have to click a few times randomly on the stage to get the trace statement.
I thought when I add this event listener to the stage, it should respond to any mouse click within the swf area, no?
View 2 Replies
Aug 8, 2011
I have a button with a MouseEvent.CLICK listener. The CLICK event is being triggered when the button is pushed, mouse is down while rolled out, then released when rolled in on the button again. I do not want this to happen, the click event should not occur when the button is being dragged.
My flash file contains a large amount of buttons and click listeners, I would like to solve this problem with as little code as possible. What is the simplest solution to this problem?
View 2 Replies
Oct 10, 2011
I created a simple video and I tried attaching a mouse click event to it but the event doesnt fire. Here is my code:
var connection:NetConnection;
var stream:NetStream;
var video:Video;
[code]....
why wont the mouse event work?
View 1 Replies
Aug 26, 2010
Is there a way I can remove the MouseEvent.CLICK when I go to another scence? I tried removeEventListener but no luck.
ActionScript Code:
// on the first frame of scene 1
import flash.events.MouseEvent;
my_btn.addEventListener(MouseEvent.CLICK, playmov);
[Code].....
View 2 Replies
Jan 8, 2008
how to listen on a SINGLE CLICK as well as DOUBLE CLICK for an object?
Meaning, one behaviour if the object is single clicked and another behaviour if it is double clicked.
Simply adding two event listeners (CLICK and DOUBLE_CLICK) leads to CLICK handler getting called always.
I understand one could start a timer upon the CLICK and if another CLICK doesn't arrive within 'x' milliseconds generate a SINGLE_CLICK event, else generate a DOUBLE_CLICK event. It seems like a hack and dependant on CPU load.
View 14 Replies
Feb 17, 2009
I have unit A: on a mouseEvent: MouseUp and MouseDown event. I'm going click and dragging objects.
Unit A when I pick it up says I have picked up Unit A. I drop it in a location and it stays. GOOD
I pick up Unit B and it says I picked up Unit B. I drop it on top of Unit A and it says I have dropped Unit A. NOT GOOD.
I only want to drop unit B, not A. So I looked at the events:
Target: The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.
So I use currentTarget instead:
currentTarget: The object that is actively processing the Event object with an event listener. Except they both return the same. Both will register Unit A, even though I am holding Unit A.
View 1 Replies