ActionScript 3.0 :: DispatchedEvent Not Being Heard By Listener?
Mar 14, 2011
I have 2 classes, one is Ticket_mc() and the other is TicketPurchaserFSlider(). there is a number stored in TicketPurchaserFSlider() called ticketsSelected which holds the number of tickets i have selected. Now what i want to do is to be able to increment that number by one from the Ticket_mc() class. and how i set that up was to create an dispatchEvent(new Event("selectFromList")), and then a listener and a function conected to that listener. anway its not working. Here is my code:
I have a mystifying (to me!) problem with using non-built-in events. I would like to dispatch an event with its own name and have an object on the stage listen for the event. As far as I can tell, the event is getting dispatched, but the object doesn't hear it.
I seem to have run in to an issue where a custom event is not being heard between objects. Here is my set up: I have two classes, GameBoard and InstructionsBoard, each is linked in the library, in the properties panel as a class to movieclips on the stage.
I dispatch an event from my GameBaord class: dispatchEvent(new CustomEvent(CustomEvent.ANIMATION_DONE));
I've been experimenting with writing my first custom event So I have a MovieClip class in the library called "Curtains". It plays an animation and at the end of the animation I have the
i am having some problems linking my mp3 player swf file to my website. It looks like it loads fine, and the buttons work and change the track of the song, but there is no sound heard or played. Here is the code i used to do this:
[CODE].....
As i said before, the player loads up and shows up on the website with no errorsand the buttons work (going to next or previous song as well as the pause and play buttons pausing and playing the music properly), but no sound can be heard. (this is being test on the latest version of firefox).
TypeError: Error #2007: Parameter listener must be non-null.at flash.events::EventDispatcher/removeEventListener() at project1_fla::MainTimeline/btnName()
I am having a weird problem with scope/reference. I am using a loop to preload a number of thumbs in one go, I am creating a different listener for each one on the fly and then passing event handlers for each one of them. This should not be difficult using a loop, but somehow I cannot access the the parent object on my listener and therefore I can't do much with my thumbs after they are loaded.Here is the relevant segment of my code. myThumb_mc is a temporary variable that does not exist when the loop finishes, you can copy and paste this code to test it though. It should work to that extent. (you'll need an image1.jpg to be in the same directory)
Code: var myThumb_mc = _root.createEmptyMovieClip("myThumb_mc", _root.getNextHighestDepth()); myThumb_mc.clipLoader = new MovieClipLoader(); myThumb_mc.clipLoader.loadClip("image1.jpg",myThumb_mc);[code].....
The code above works, but it does not look nice and it cannot be the right way of doing this. Long question short, how can I access the parent of a listener from a listener object? ._parent does not work.
This is something that tugs at my mind a lot so I figured I'd ask the community. If I have a class called MyParentWidget and it contains an instance of MyChildWidget with an instance name of myChildWidget then I will often do something like this:
Quick question, can an object get the same event listener applied more than once? For instance if I have myObj.addEventListener() and then later in my application I apply the same exact listener on the object again does the listener get applied on the object thus increasing memory consumption? or does it get re-written over?
I am trying to add a key listener. I'm pretty sure this was working recently, but now it isn't, and can't figure out what is preventing it... I am saving in Flash 6.
var myListener:Object = new Object(); myListener.onKeyDown = function() {
I tried to add a listener but nothing happens....I mean nothing happens.
keyListener.onKeyDown = function() { if (Key.isDown(Key.TAB)) { if(des.text != "FRED"){[code]...
We want to set focus in atext field then when the user presses the Tab key we want to see what's in the field and move on the timeline.When I put the code above into a new file it works fine but if I put it into my course file or even bring it in using a loadmovie it doesn't work anymore.If I use a simple on realease key = tab on a button it works in a new file, but not in my course file.
I want to add a key listener to my stage, but from an object 2 depths below the stage. How would I do this?
I thought about adding the listener from my doc class, but the listener function is in the object that is two depths below the stage, which would mean I would have to pass the key values to the next movie clip, then when that one is loaded, pass it to the one with the listener function. It seems very complicated, is there an easier way which keeps with the principle of OOP?
I have created a listener. I want to call this listener on click on the button. As like my_btn.onRelease = function(){//call this listener on click on the button.}
i've a problem with the DOUBLE CLICK EVENT. I have a foregrounded MC, named AA(activeArea),who stands like a "event captor" covering the whole stage area, so i used it for manage every event in my swf.The problems starts when i add a listener to the MC which stands on the background, under the AA. It doesn't "listen" anything.
I have a timeline with some button (and movieclip) that will appear later ...what is the best way to add listener to them? I can't do it in the first frame because the buttons don't' exist yet... Is it a good practice to add the listener when flash put the buttons on the screen or is there a better way yo handle this situation?
I'm not getting any errors. I've been over this code again and again. I based this on an exercise from Lynda.com. The code includes listeners for mouseup but the dragged object doesn't stop dragging when at mouse-up as directed. Also, the dragged object doesn't return to original position as directed.
Here is the main .as file:
Code: private function checkTarget(event:MouseEvent):void { if(event.currentTarget.hitTestObject(event.currentTarget._targetPiece)) {
I have a document class called "RheDocClass.as". This document class instantiates a class called "LiquidGui.as".What I want to do is have the LiquidGui class listen for stage RESIZE events and the act on those events. But when I try to add a stage listener to the LiquidGui constructor I get errors. ( the error depends on how I experiment with the syntax) So I have put the listener in the RheDocClass instead, and then pass the stage properties to the LiquidGui class. But, I'd really like to keep the stage resizing code all in the LiquidGui class so that I can reuse it with other projects.how I can attach a listener to the stage from the LiquidGui class?
I've got a shell movie clip which loads some other clips. In one of the sub clips, I have a key listener. Inbetween loading of the sub clips, I have it removing the key listener and the movie clip.
But the function that was attached to the key listener is persistant, even after the sub clip has been deleted, and I've attempted to remove the key listener from the main shell. What ends up happening is the second time you load the sub clip, it runs the function *twice*, or three times, or as many times as you click the link to load it.
When i run the shell movie, it shows trace actions from the sub clip even after it's been removed!
Within flash 8 i'm working the folowing website:[URL] The centered MC size changes when clicked a button.I published the movie as a 100% x 100% with a noscale option. I want to add a movieclip in my main timeline wich must go automatically to the left of the users screen. if you got 1024x 768 and even when someone got a nice 30" screen from with a resolution from 2560x1600. yesterday i posted a thread and i've got the next code wich did not work in my movie. the next code i placed in my main timeline:
I tried several things today but nothing works. i tried different publish settings. the listener option was new for me and i tried to find out what it does.do i need to add a line like addListener? or do i need to name the function?
I'm building a center stage object and I wanted to know if there's any way to add a event listener that checks if the children have changed in size.[code]This seems like it should be available but I can't find a reference.
I'm trying to set up a keyListener that would activate and deactivate under certain circumstances. For instance, it needs to deactivate if a key is not pushed a short time after something unrelated happens.In order to do this, I'd need to have the removeListener method outside of the Listener function, but it doesn't seem to remove anything when it's not in the function. Is there something else I can do, or am I doing something wrong?