ActionScript 3.0 :: Disable Click Event When Object Is Hidden?
Nov 8, 2011
I have a game where "targets" hide behind trees and when they pop out from behind, you click them and they are destroyed. For some reason though, when you click the tree they are hiding behind, they still get destroyed. I want them to be safe from the user clicks when hiding. Here is a sample of the code I am using:
Code:
stage.addEventListener(MouseEvent.CLICK, onClickHandler, false, 0, true);
function onClickHandler(event:MouseEvent):void
{
[code]....
I tried adding an else if statement like so:
Code:
else if(bullet.hitTestObject(backtrees)) {
poof.x = bullet.x;
poof.y = bullet.y;
[code]....
but that did nothing as well. As you can see, it is not the click of the user that causes the target to disappear, but the hittestobject that causes it to disappear.
View 2 Replies
Similar Posts:
Mar 6, 2012
I'm trying to disable the button click event on a button with no luck.I did some searching but it would always display an error.
button_1.addEventListener(MouseEvent.CLICK,mouseUp Handler);
function mouseUpHandler(evt:MouseEvent):void {
gotoAndPlay(2);
[code].....
View 3 Replies
Jul 20, 2011
I wanna disable click event of datagrid of top columns, which is showing catagoeries string values.
View 1 Replies
Apr 10, 2012
I'm currently design an application that when a button is pressed it expands to display further information.A major issue I am faced with is that if the button is pressed whilst contracting so that it expands again, the co-ordinates are saved from when it was clicked, meaning it will never return to its original state.
I either need a way of disabling the mouse click on the button whilst the TweenMax is doing its job in contracting the button, or by extracting the coordinates from an array. I've managed to get the array of coordinates from my menu class into the main class, but can't work out the best way in order to stop the problem from occuring.
[Code]...
View 1 Replies
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
Feb 23, 2009
I'm trying to add an event listener inside an object but it doesn't seem to work. other OO languages it makes sense for an object to be able to attach events etc itself rather than have some external action do it.Here's an example of what I'm trying to do:
ActionScript Code:
package {
import flash.display.MovieClip;
public class Player extends MovieClip {
[CODE]....
This gives an error "1120: Access of undefined property MouseEvent." suggesting that I don't have access to MouseEvent from within the instansiated object.What I can do is create an instance of the class from the Document Class for example and then do the following:
ActionScript Code:
newInstance.addEventListener(MouseEvent.CLICK, newInstance.mouseClick);
View 1 Replies
May 4, 2009
I'm having a problem where buttons and MCs are receiving clicks even when they are either hidden (opacity=0) or below another layer.
View 5 Replies
May 18, 2009
MouseEvent.target will return the target object... but how do I access the specific object type? I know it's probably simple... but it's late and I'm fried. The code below obviously doesn't work. I just need someone to tell me what to put instead of [object MovieClip] and [object SimpleButton]
Code:
stage.addEventListener(MouseEvent.CLICK, fOnClick);
function fOnClick(e:MouseEvent):void {
[code].....
View 10 Replies
Mar 4, 2010
Is it possible to do something similar to this pseudo code?
var oMouseListener:Object = new Object();
oMouseListener.onMouseUp = function() {
if (Mouse.clickTarget is a MovieClip) {
[code]....
View 5 Replies
Mar 18, 2012
Possible Duplicate:ActionScript 2 Moving an object I am new to AC. I have a button and a object. Is there a way for the object to move horizontally if i press down on the button in Action Script 2
View 3 Replies
Dec 8, 2011
Possible Duplicate: ActionScript 2 Moving an object I am new to AC. I have a button and a object. Is there a way for the object to move horizontally if i press down on the button in Action Script 2
View 1 Replies
Apr 18, 2004
Is it possible to do something similar to this pseudo code?
var oMouseListener:Object = new Object();
oMouseListener.onMouseUp = function() {
if (Mouse.clickTarget is a MovieClip) {
[code].....
View 5 Replies
Jun 29, 2011
I'm just trying to understand a difference between IE, Chrome and Firefox. I have the following code on a page:
$('object').live('click', function(){
alert('Fired');
});
I then populate the page with some Flash controls (in my case, I'm using Uploadify). When I click on the Flash control, I see the alert in Firefox 4. However, I do not see the alert in IE8 or Chrome (I havent tested any other browsers).
View 1 Replies
May 11, 2010
" I have 3 different video in (layer "content) each video in different frame(Video1 in frame 1),(video2 in frame10),(video 3 in frame 20) ..Also, i have 3 different buttons in "buttons layer" ( button1, when click, it play video1) (button2, when click, it play video2), (button3, when click, it play video3)...what i need when i click button1 and play video1 all the buttons should be hidden... when the video finish playing it should be appear again... same thing for button2 when i click it and play video2 all the buttons will be hidden until the video finish playing .this is my code
Code: Select allvideo_button1.addEventListener(MouseEvent.CLICK,clickListener1);
function clickListener1(event:MouseEvent):void {
[code].............
View 2 Replies
Feb 8, 2010
I'm currently working on a game that has multiple 'scenes' located on each frame. In one scene, if you click on an object it disappears. I did this using the visible = false method. However, anytime you return the scene after, the object is visible again. How would I write the code so that it stays invisible permanently when you click it, regardless of whether or not you leave and later return to the scene?
View 4 Replies
Apr 14, 2009
I tried adapting a bit of script from one Tonypa posted some time ago about making a hidden objects game.I want to have a movieclip play on top of a randomly selected movieclip from an array, but I don't seem to have it.Here is the hint script part.....
this._parent.hint.visible=false;
function showHint () {
var n=Math.floor(Math.random()*this._parent["object" + i].length);
[code].....
View 1 Replies
Oct 27, 2010
I'm currently trying to build a hidden object game, but am having difficulty getting accurate results with where the mouse is clicking. I thought using hitTestPoint to check whether the mouse's coordinates were actually colliding with the pixels of the shape would work, but this produces the exact same results as simply checking for a MouseEvent.CLICK event. It seems to be returning true even if the pixels being clicked on are transparent (i.e. just background/not part of the shape). Is there any way to check whether the pixels being clicked on actually contain the image of the object being searched for?
[Code]...
View 5 Replies
Nov 29, 2010
I'm using jQuery Autocomplete just as in this example: [URL] The problem is, the area where you see the Result box in that example - that's where my flash object is. So, when the autocomplete dropdown appears, most of the text is concealed by the flash object (which I can't move). How can I make the autocomplete text appear over the flash object (concealing its view rather than vice versa)?
View 4 Replies
Jul 7, 2011
I am trying to learn JavaScript and I am wondering whether JavaScript has a event listener just like ActionScript's ENTER_FRAME. Basically, I want this event listener to listen "all the time" not just wait for any particular instance (mouse click, keyboard event) of event.
View 3 Replies
Feb 5, 2012
how I can disable clicking through an object so it doesn't effect anything under-neath the object when pressed.
View 9 Replies
May 19, 2011
on clicking the Search Icon , a search bar will be visible (ON) if user click anywhere on the stage the search bar will be NO visible(OFF) OR user click on ICON again the search bar will be OFF but it Stage CLICK is triggered without clicking
[Code]...
View 1 Replies
Feb 3, 2011
can i define a flash event as double click or single click
View 3 Replies
Jan 26, 2012
I just started playing around with as3 and I have a function for mouse clicks that draws a shape on each click. However the mouse click event does not appear to work unless I click a movieClip object I placed in the middle of the screen. Is there a way to make the mouse click event recognize when I click anywhere on the screen?
[Code]...
View 2 Replies
Dec 15, 2009
How do I disable right click functionality for SWF? When I right click on this movie that I have it gives me option to click on a link.How do I take the link out or diable the right click function?
View 2 Replies
Feb 14, 2010
I would like to disable left clicks certain keyframes, i have a movieclip that the user is dragging and when a click is made it has a short animation, but i dont want users to be able to click other things while this animation is running. so i need to disable the left click. the animation is on inside the movie clip.
View 5 Replies
Feb 15, 2006
i would like to know how to disable mouse right-click on flash.maybe there are posts here on kirupa on how to do it but i don't really have a fast internet connection to browse around.
View 1 Replies
May 22, 2003
is it possible to diable right click menu using just actionscript in a .swf ? I know if i use <param name=menu value=false> in the html it will disable the right click menu but.... i am just using the swf and wanted to knwo if it is possible to disable right click menu without using html.
View 12 Replies
Feb 3, 2012
I want to add a Single Clcik event and Double click event both on the same movie clip in as3 , its working but call both the event same time so how to fix it
View 1 Replies
Feb 27, 2007
I'm moving on to my next massive programming project and I'm trying to decide whether I should code it in as 2.0 or 3.0. I came across the new click event model in 3.0. Right now it's looking like a pain in the butt to me. So now I have to make a function and add it as an event listener? what the hell? What's the benefit? I understand stuff like this makes AS a more complete language but it's kinda annoying.
View 1 Replies
Apr 10, 2009
i have made a sniper style game an hav programme a moment where there is pause between each click (reload time) but how do i make it so that when the gun is reloading the left click is disabled, as it stands now while the gun is reloading the aim doesnt move but if u click on an enemy they still die as it stil sees it as clicking on it, how do i disable it for these 2 seconds while my gun reloads
View 1 Replies