ActionScript 3.0 :: Disable All The Event Listeners For Few Seconds?
Feb 26, 2009Can I disable all the event listeners for few seconds ?
View 3 RepliesCan I disable all the event listeners for few seconds ?
View 3 RepliesIs possible to disable all the eventlisteners with one single command ? maybe disabling mouse ?
I need to disable them for few seconds without having to disable each one per time
I am implementing several listeners in my application, but they seem to slow my XML load function significantly...I would like to disable my listeners until the load is completed.
View 1 RepliesI have an input textfield and some keys listeners on the stage. When typing in the input textfield the key listeners of the stage and loaded swfs get triggered. I've tried different things with focus and stopPropagation but nothing's been working, at least the ways I've been implementing it.So my question is, "How can I make it so that when I am typing into the input textfield, none of the keylisteners get triggered?"
View 2 RepliesI 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?
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?
Does anyonen know how to globally disable/hide the yellow focusrect without affecting key listeners?
View 3 RepliesI'll explain the problem I have having as Im sure there are a few solutions, I have a flash website which has four main links, HOME, SERVICES, BLOG, CONTACT.
When the services button is pressed 5 more buttons come in from the right hand side each is slightly delayed to give a stacking effect.
The problem is if the user clicks on the Services button and then quickly presses the another button the service buttons tween in onto the wrong page!
The solution I am thinking is to set a time delay on the services button so when it is pressed the other buttons are delayed for a few seconds to give time for all teh serivecs buttons to tween in.
If so how could I implement it? I have bene trying many things to get it to work, I almost have it, but the delay only works the first time the button is pressed and I cant seem to get the timer to reset!
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].....
So I've gotten into using my own as Classes, and have an interesting question.
My main swf calls a php script that gets data from a mysql database which is returned as XML. Part of that data that is retrieved is a filepath to a jpg image. It then takes that filepath and other information, and passes it to my external class, the "news story" class.
All fine and good. Then, the "news story" class uses a loader to load that image along with some text, organize it, and voila, you've got your own very pretty "news story". (I'm extending the MovieClip class here, though I suppose it doesnt matter)
Now, my main swf uses this component to load multiple of these "news stories". The problem is, theres that load time for the image. The main swf is loading them all one at a time, because they are putting each one together on their own.
The key here is that it be dynamic. So, since we don't know how much text is in each "news story", we also therefore don't know it's height. What I'm doing is creating each story in the main swf, pushing it into a "news story" array, adding an event listener to each ones' loader, and when the event listener is triggered, I want it to go to the 'add content' function where it sets the news story's Y value based off the position and height of the previous story that was added (stacking them, obviously). This makes sense, because otherwise it'd add them all on top of each other and it'd be a jumbled mess.
The problem is, the event listener is on the loader object INSIDE the component actionscript. So, how do I figure out which news story to set the Y value for? Because the eventlistener is listening to the loader, not the class. I hope this makes sense AT ALL. Here is the code:
Quote:
while (fancy shmantzy conditions)
{
/*creates the news story and passes xml data to it (filepath, etc)*/
storyBlock = new StoryBlock(a bunch of parameters);
subCBArray.push(storyBlock); //array that stores each news story info
[Code]....
I have made an event listener:text0_mc.addEventListener(MouseEvent.CLICK, showMe);showMe is a function, but I need it to call more than 1 function at once i.e. -ext0_mc.addEventListener(MouseEvent.CLICK, showMe1, showMe2, showMe3, showMe4, showMe5, showMe6, showMe7);Each function contains an if statment as below.
function showMe1(event:MouseEvent):void
{
if (shuffledArray[1]==orderArray[1]){
[code].....
In AS2 you could add an onRelease to multiple buttons like this:
Code:
onebutton.onRelease = anotherbutton.onRelease = lastbutton.onRelease = function() {
//do something when either button is pressed;
}
Is there something similar possible in AS3 using addeventlistener? Besided copying the same addeventlistner line for all individual buttons?
Lately I've been twitching in the back of my head wondering just how many references to objects that I'm making, and whether or not they are getting GC'd or not.My question in this sense refers to event listeners and whether or not they are removed in certain cases where you get rid of an object. Two examples:
First, and I think this one is an easy one... when you create an object that adds an event listener to itself INSIDE it's own methods (e.g. this.addEventListener(e:Event, function)), when you REMOVE that object (this), do it's event listeners disappear too? I can only say yes, because they are referencing THAT object and are INSIDE that object.
So I think that question answers itself (but I'd love to know if the truth says otherwise).
But secondly, if you add an event listener to an object from a sibling or parent object, and then remove the object, does that event listener stick around, therefore maintaining a reference to that object and keeping it in memory? And is that the concept that people keep referring to of 'weak' event listeners? E.g. someChildObject.addEventListener(e:Event, function)Also, are event listeners by default strong or weak?
And I am assuming that 'yes', it DOES keep the reference. Which, if you are a n00b programmer like me, you probably are all like, 'aww sh*t damn, how am I supposed to make sure that my objects are getting thrown in the garbage collector's mouth of goodness every once in a while?
I found this code for a contact form at[url]...and it dynamically creates input fields and buttons. I didn't like the dynamically drawn submit and reset buttons, so I added my own MCs(my 'buttons') to the stage.I tried modifying the code and took out the dynamically drawn buttons..However, I cant figure out how to add Event Listeners to the buttons which exist on the stage--Im getting undefined errors...[code]...
View 2 RepliesI have a movielcip (A) class in which I have used a Tween class effect on a child movieclip (B) scrollRect. The (B) Movieclip in turn has several movieclips whose have tween class effect being executed on thier child movieclips.the tweens are all unique to each movieclip and the event listeners are taken off once completed.This works all well and good in FLASH IDE..My problem arises when I try to view this in a browser on a Windows XP.[code]
What is happening in most cases it that the animation appears to "stick" but i think what may be happening is the listening or removal of the event listeners. The animations are left incompleted.Is there any rule of thumb when using multiple event listeners?[code]the effect disables and re-enables the buttons when its done.... then the listeners are removed.each one with the exception cretes its own unique tween (obviously this is a custom class built as each clip)
If you have multiple event listeners running, is there any way to remove all of them at once rather than one at a time?
View 3 RepliesI have an array that returns multidimensional data from an mysql database, when this is collected the createNews function creates the user interface. The problem I am having is the loop is iterating quicker than the UI is being created, is there a way to use event listeners with loops so it only continues after my function has completed its work?
[Code]...
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.
How do I define my own event listeners in AS3?
View 3 RepliesI 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);
}
How do you know when you should remove event listeners? For example, I know that if I have a TimerEvent listener, I can safely remove that event when I have stopped and / or deleted my timer. Or, if I have a display object on the stage, and I remove it, I can safely remove any event listeners associated with the display object.
View 1 RepliesI've placed listeners on the var "topic_mc" (below), but I'm not sure how to remove them properly:
Code:
private function layoutTopics(modNum:Number, attachTo:MovieClip):void {
topicLength = MainMenu.modArr[modNum].topicArr.length;
if (Interface._ui != null) {
[code]...
doesn't really work - the listeners keep running. How do I call the objects properly to remove the listeners?
Im sure this has been asked a million times, so forgive me but I cannot seem to find an answer or my search query is wrong. I am using Tweener for animation.
I have 2 MC's on my stage. I have an event listener for my main MC (MOUSE_OVER, MOUSE_OUT) that triggers Tweener to animate another MC on top of the main clip. The problem is that when it overlaps the listener no longer works, and tried to execute the MOUSE_OUT. I understand why its not working, I just cant find a solution. Here is the code and a simple FLA.
ActionScript Code: import caurina.transitions.Tweener;
square.addEventListener(MouseEvent.MOUSE_OVER, RollItIn, false, 0, true);
square.addEventListener(MouseEvent.MOUSE_OUT, RollItOut, false, 0, true);
function RollItIn(evt:MouseEvent):void {
[Code]....
well i wish to know, whats the maximum amount of events which can be called?
previously in as2 i ran into this problem when i kept using roll over and roll out events. and very quickly it reached its limit. so i wish to know what the maximum is, and is there any efficient way of asking flash how many are being called?
let's say i have a function that is
function myFunction(argument1:int, argument2:int):void {
trace(argument 1 + argument2);
}
i can use myFunction(1,2); to get a trace of "3" but if it's a mouse event, or timer event, or anything myMC.addEventListener(MouseEvent.MOUSE_DOWN, myFunction); we can't put arguments in this because it would have been
[Code]....
I've an array of movieclips created via code that have some textfields. Then i have added some listeners to the movieclips.
Here the code:
Code:
arrNot[i].addEventListener(MouseEvent.MOUSE_OVER, titoloOver);
private function titoloOver(e:MouseEvent){
var nome:String = e.target.name;
TweenMax.to(curs,1 ,{y:contMain.getChildByName(nome).y + 23});
}
This code moves a cursor calculating the y coordinate depending the moviclip that is mouse overed. Now the movieclips have some textfields so when i mouseover the movieclips all works ok but when i mouseover the textfield i receive a #1009 error.
I have 8 movieclips on the stage: but1,but2,but3,..,but8.How do I use a for loop to add event listeners to each? I am trying this, but i'm sure its not correct:
Code: Select allfor (var i=1;i<9;i++){
but[i].addEventListener(MouseEvent.ROLL_OVER,onOver);
}
I've placed listeners on the var "topic_mc" (below), but I'm not sure how to remove them properly:
Code:
private function layoutTopics(modNum:Number, attachTo:MovieClip):void {
topicLength = MainMenu.modArr[modNum].topicArr.length;
if (Interface._ui != null) {[code]....
doesn't really work - any trace statement I place within the event function will run for infinity. How do I call the objects properly to remove the listeners? Note: I've tried referring to currentTarget instead of target but that doesn't make any difference.
Can you put event listeners on bitmaps? Because the current project that I'm working on requires a lot of separate objects which are currently MovieClips, and because there can be several hundred, it causes the app to lag.
View 1 RepliesIm just trying to add an event listener to all of the objects in an array I have posted my error and the code below.
error:
TypeError: Error #1006: addEventListener is not a function.
code:
mainMenuArray = new Array([introButton], [photographyButton], [graphicsButton], [contactsButton], [projectsButton], [linksButton]);
private function firstMenuListeners()
[Code]....