Flash :: Why Are Event Listeners Firing More Than Once

Jun 14, 2010

In my Flash project I have a movieclip that has 2 keyframes. Both frames contain 1 movieclip each.

frame 1 - Landing
frame 2 - Game

The flow of the application is simple:

User arrives on landing page (frame 1) User clicks "start game" button User is brought to the game page (frame 2) When the game is over, the user can press a "play again" button which brings them back to step 1

Both Landing and Game movieclips are linked to separate classes that define event listeners. The problem is that when I end up back at step 1 after playing the game, the Game event listeners fire twice for their respective event. And if I go through the process a third time, the event listeners fire three times for every event. This keeps happening, so if I loop through the application flow 7 times, the event listeners fire seven times. I don't understand why this is happening because on frame 1, the Game movieclip (and I would assume its related class instance) does not exist - but I'm clearly missing something here.

I've run into this problem in other projects too, and tried fixing it by first checking if the event listeners existed and only defining them if they didn't, but I ended up with unexpected results that didn't really solve the problem.

View 2 Replies


Similar Posts:


Flex :: Event Listeners Not Firing In Code

May 15, 2011

event listeners not firing in this code can anybody guide me what is problem with this code.[code]

View 2 Replies

Flex :: Programmatically Firing Event Listeners

Nov 10, 2011

I would like to programatically fire an event on a spark checkbox. I have a tab bar which has tabs enabled according to various checkboxes. I am loading data into these tabs. Sometimes tabs 1 and 2 will be enabled. Other times tabs 2 and 3. Other times tab 4 by itself (and all the other combinations). I have tried to enable the VBox (in action script) which is in my view stack but it seems to freeze the application. The VBox enables correctly upon user input on the check box. If I set the checkbox to be selected it does not fire the event and so does not enable the tab.

Is it possible to manually fire an event in Flex. I have tried to see if I can take the checkbox and get the event and fire it. Unfortunately I can only see addEventListener, hasEventLister and removeEventListener. There is no way of getting the events that are already on the checkbox

View 1 Replies

ActionScript 3.0 :: Why Are Functions With Event Listeners Firing Themselves Again

Aug 23, 2009

I've had this glitch for a long time, and I've tried several ways to get rid of it, and now that I just recoded everything to see if it was something I did, it's back again! basically, whenever I press space (regardless of whether or not I am listening for a space press [or any key press]), the last function fired by an event listener will run itself again, with the exact same arguments supplied to it in the first time.

For example, if I make a simple button to trace("text"); and take you to another frame. Once you get to that frame you can press Space and it'll trace "text" again! I really have no idea what's causing this, and it doesn't seem to be happening to me in new files. and there's too much code to show you, but I just want to know if anyone has heard of this before or if they have any theories to what's going on.

View 7 Replies

ActionScript 3.0 :: Event Listeners Not Firing Consistently?

Oct 7, 2009

I have 9 buttons on my site which I wish to increase to 100% alpha when the users mouse rolls over each one, then have the alpha reduced to the original setting of 75% on rollout.If I set the code below for 1 button it works just fine. However, if I repeat this code just changing the numbers for each button, it stops working once duplicated more than a couple of times.Why does it stop working and how can I write this efficiently so it works for all 9 buttons?

Here is the code:-
addtocart1_btn.addEventListener(MouseEvent.MOUSE_O VER, fadeinaddtocart1);
function fadeinaddtocart1(event:Event):void

[code]......

View 3 Replies

ActionScript 3.0 :: Keyboard Event Listeners Not Firing?

Nov 17, 2009

It currently has the following listeners active. When you click a blurb, you will zoom into it. When you click it again (or anywhere on the flash object) it will zoom back out.If you let it idle it will zoom in and out at roughly 10second intervals.There are also keyboard functions that when you click on the arrow keys it will move the camera in various ways. The keys only work in the zoomed out state and are disabled on zoom inThe problem that I'm having is with these. On startup, the keys work fine. If you let it idle and have it automatically zoom in then out, the keys will work fine. However, if you manually click out of a blurb, the keyboard event listeners stop working. I'm not sure why this happens since both the auto-zoom and the manual zoom both call the same function to zoom out.

At first it seems to be that the window is losing focus, since if I click on white space I can use the keyboard again. The problem though, is that when I use an DEACTIVATE event listener to test it, it doesn't show the flash object losing focus. Because of that, I'm not really sure how I would go about fixing this problem.

Code:
package com.jonchau.twitter {
import flash.display.MovieClip;

[code]......

View 1 Replies

ActionScript 3.0 :: MouseEvent Listeners Not Firing - But No Errors

Jul 31, 2009

The problem is with addAnimation()

ActionScript Code:
package
{
import flash.display.MovieClip;

[Code].....

... then it works.

But I don't want the movieclip on the root like that, I want it within main.page1

View 3 Replies

Javascript :: Mouseup Event Over Flash Object Not Firing?

Apr 8, 2011

I have got this script working from How to get mouseup to fire once mousemove complete working within the jQuery (document) scope.Later on I added a flash object inside the body.and when I click on the flash object the mousedown event fired, mousemove event fired, but not the mouseup event which where I want to unbind the mousemove. But when I click on non Flash area, mousedown works, mousemove works, and mouseup also works. It works like I wanted it to in Chrome, but not in Firefox.Here are the codes, and I called handleMouseDown in $(document).ready

handleMouseDown: function () {
jQuery(document).mouseup(function() {
Log("unbind.");

[code]........

View 3 Replies

Flash :: Custom Event Not Firing On Document Class?

Apr 28, 2011

Im trying to get my head round what is needed to catch event "Beep2", using dispatchEvent. The function "DoNext" is not firing, even though Im able to produce a trace result of the dispatchEvent "Beep2 true".

This code uses a CustomEvent Class to Extend the Event Class. Its right on my limit of knowledge so far,

[Code]...

View 1 Replies

Flash :: Prevent Touch Event From Firing From Under Another Sprite

Dec 6, 2011

I'm trying to make a vieport in which you can pan by dragging the background image around. Here is what I've done: [URL] Note that I've hidden the mouse cursor and replaced it with 2 custom ones. The problem is, the event attached to the background, which is a touch event, fires even when the mouse is over a sprite/movieclip (the monkey or the stats) that's in front of that background. And the stats isn't even in the gameLayer (where the monkey and the bg and the mouse cursors are). Try to drag the stats around, and see that the background and everything else pans with it (this is unwanted). Also, I need to remove the custom cursor and show the regular cursor whenever the mouse is NOT on the background (i.e. when it's on the monkey or stats or any new sprites I may/will have in the future).

[Code]...

View 1 Replies

Actionscript 3 :: Flash - Loader Event Not Firing In Firefox?

Mar 15, 2012

I just inherited some code that produces an embedded rdio music player into a swf. It works great in firefox and safari, except the embedded player does not appear in Firefox... :(

Is this a common issue with the Loader class or contentLoaderInfo events?

import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;

[Code].....

View 2 Replies

ActionScript 3.0 :: Flash - Event.COMPLETE Never Stop Firing?

Aug 1, 2010

I write directly on the time line on the scene and, well... the code looks fine to me, but my list of slideshows (which is what the xml contains) keeps on repeating itselfe... here is the code:

var uloader:URLLoader = new URLLoader();
//var slide:Slideshow = new Slideshow();
uloader.addEventListener(Event.COMPLETE, loaderCompleteHandler);

[code]....

View 1 Replies

ActionScript 3.0 :: Event.deactivate Is Not Firing With Flash Plugin 10,2,152,26 Embeded In IE 8 And Above

Feb 23, 2011

I am working on a portal which is built in flex. I wanted to perform some action based on my applications is in focus or out of focus. So  I tried to use two Events for this purpose Event.Activate and Event.Deactivate inside my flex code.
 
These events fire perfectly in FF 3.0 and above, Safari, Chrome and these events get triggered till IE 7.
 
But when I switch to IE 8 and above versions with latest flash player plugin 10,2,152,26 the Event.deactivate is not firing, and I am not able to detect whether my Flex application is out of focus.

I tried doing some research around this issue both using Flex Events and Javascript approach using window.onfocusin and window.onfocusout, but still no luck in IE 8 and higher versions with latest Flash plugin 10,2,152,26.

As we have a large number of users viewing this portal in IE 8 with latest flash plugin.
 
The code is simple and I have pasted below:
 
package {
import flash.display.*;
import flash.utils.*;

[Code]....

View 3 Replies

Actionscript 3 :: CHANGE Event Not Firing From Numeric Stepper (Flash)

Nov 8, 2011

I have a Numeric Stepper. If I click on the plus or minus my event will fire.

[Code]...

However, when my function changes the value based on a button press, the Numeric Stepper will update the number but it will not fire the CHANGE event.

[Code]...

View 1 Replies

Javascript :: JQuery Flash Object Click Event Not Firing In IE Or Chrome?

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

Actionscript 3 :: Flash Filereference Select Event Not Firing After Using Browse() And After Selecting A File

Aug 11, 2011

This is the first time i am working in action script. I have seen a flash programmer working with it. since i know javascript i was able to work in action script. I am creating a file upload component for my php projects. Until now i have advanced to show the file dialog box using the FileReference api. The select event is not firing for me. and i did not get any error.

[Code]...

View 2 Replies

AS3 :: Flash - Define Own Event Listeners?

Nov 9, 2010

How do I define my own event listeners in AS3?

View 3 Replies

AS3 :: Flash - Removing The Event Listeners?

Dec 17, 2010

I have a basic question about manually removing event listeners in actionscript 3.If I have a function like:

private function doStuff(event : Event):void
{
//let them save
var f:FileReference = new FileReference();

[code]...

How do I remove the event listeners when the saveDone function is called? Normally I just change the "add" to "remove" like:

f.removeEventListener(Event.COMPLETE,saveDone);

However, f is a local variable, and I can't get to it after the doStuff function ends.

private function saveDone(ev:Event){
f.removeEventListener(Event.COMPLETE,saveDone);
}

View 3 Replies

Flash - Event Listeners And Syntax For The Actionpanel?

Mar 4, 2010

I've done most of my code in as3, working from either document class or classes. I've never done action script from within the actions panel (within Flash cs4). My question is do I need to follow the as2 manual in order for majority of code to work ? for example. If I want to do a loop. I can't do a

addEventListener(Event.EnterFrame,loop);
I have to do
varible = onEnterFrame()

[code].....

View 2 Replies

ActionScript 3.0 :: Flash Event - Add Listeners On A MovieClip

Feb 22, 2011

I have this problem with mouse events simply I added two listeners on a movieClip that simply contains two keyframes 1 and 2 the code is in external class file of the movieClip

[Code]...

but when it goes to frame 2 it does not answer the moseUp event and stucks in frame 2

View 1 Replies

Flash :: Loaded SWF (using Loader) Event Listeners Sometimes Fails

Jun 9, 2011

i made a SWF which contains a loader which loads any SWF file passed to it... the problem I'm encountering is that for some SWFs, some event listeners doesn't fire anymore... my own SWF file (which contains the loader) doesn't really have any other element except for the Loader object and so I cannot understand what seems to be preventing the loaded SWF (loaded by my Loader) from receiving some mouse events

it seems that the for the SWF where I'm having this problem, the listener seems to be tied up to a location in the stage or somewhere else, and so whenever I resize, the listeners is not responding on the right place, for example, the button appears on a certain position but the listener's hit test or whatever the SWF is using to detect the mouse click is positioned somewhere else

View 1 Replies

ActionScript 3.0 :: Transparent Flash - Event Listeners On Different Browsers?

Nov 19, 2010

looks like flash has few issues when using transparent mode on different browsers players. Adding and removing eventlisteners on buttons are acting different. In some players everything works OK. FF and Chrome, but in IE, one of my buttons triggers the function even after removing its listener. Is this known issue, and is there any global set I can use to prevent this?

View 1 Replies

ActionScript 3.0 :: Flash Adding Event Listeners To 150 Items

Jan 6, 2011

I'm trying to make a flash version of those refrigerator magnet poetry kits. As such I have about 150-180 little MCs each with a different word. They are all named sequentially, so theoretically I could just make some array counter or something to stick the handlers on right?

View 5 Replies

Actionscript 3 :: Removing Event Listeners Not Working - Error #2094: Event Dispatch Recursion Overflow

Nov 24, 2011

I have this in my constructor:

[Code]..

The problem is I get Error: Error #2094: Event dispatch recursion overflow. Why does removechild keep getting called if this.parent does not exist? Why doesn't removing event listeners work?

View 1 Replies

ActionScript 3.0 :: Can Event Listeners Only Be Added To The Class Which Dispatched The Event

Sep 3, 2009

Can event listeners only be added to the class which dispatched the event? I ask because I want to have the logic for the listener on the main class, and the action is dispatched on click from a thumb which is instantiated in a scroller class. Kinda like this:

ActionScript Code:
pseudo code:
class main {
main() {

[code]....

This doesn't work. Why can't the main class listen for an event on the thumb class?

View 1 Replies

Flash :: Add Event Listeners To Objects In SWFs That I'm Loading Dynamically?

Jan 12, 2010

I have a parent SWF (Parent) that handles user navigation between multiple children SWFs (Child_1, Child_2, Child_3). How do I add event listeners to the navigation buttons on the children SWFs so that the user can move laterally between Child_1, Child_2 and Child_3? I can think of two options but can't get either one to work:

1) The parent SWF sets up the event listeners when it loads a child. So, I use a loader on Parent to load Child_1 and in Parent add eventlisteners to Child_1.myNavigationform.myButton.

The problem here is that the Parent is only handing the loader instance and I can't think of how it would drill down to the individual objects within Child_1.

2) Child_1 adds the event listeners to its own objects. This just reverses the problem. Child_1 has no problem accessing its own buttons but when a user clicks them it has no way of accessing methods on parent so that Child_2 can be loaded.

View 1 Replies

Flash :: Keeping The Number Of Objects And Event-listeners On Stage As Low As Possible

May 23, 2010

I am creating a site with lots of big scrollable text-boxes in it. Each text-box object contained some text, and two buttons to scroll up/down with. The scroll buttons each had an event listener so the text moved when you clicked them.

These text-boxes were stacked on-top of each other with all except one having an alpha of 0. If I wanted to change which text-box is active I move it to the front and call a small TweenLite animation.

To the left (outside of the text-box objects) I have an object similar to a menu. It also has about 12 or so event-listeners (one for every button).

This turns out cause A LOT of lag an it's very troublesome for my laptop to run it. reduce the number of event-listeners on the stage and also the amount of text-boxes.

What I was thinking was to add the text-boxes using AS so I only have 1 on the stage at a time but I couldn't figure out how to do it. I also thought it might be better to just use 1 big event-listeners and from mouseX and mouseY decide which button the user is trying to push.

View 1 Replies

Actionscript 3 :: See The Event Listeners In Flex/Flash Builder Debug

Jul 16, 2011

Do anyone know how to see the event listeners of any component in the debug mode of the Flex or Flash builder?

View 3 Replies

AS3 :: Flash - Difference Between Adding Internal And External Event Listeners?

Aug 2, 2011

I have some MovieClip class that has eventListener, added from inside the constructor of the class (it's MouseEvent.MOUSE_DOWN). Now, I want to add the same listener externally, from parent class, for other purposes. Will these two interfere with each other or it's okay?

View 2 Replies

Flash :: Adding Event Listeners Only To Objects Which Are Defined Tank Class

Mar 3, 2012

I want to make a little game. What I need is to add event listeners to all of Tank objects inside the Battlefield instance. I just can seem to figure out how.

View 1 Replies







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