Flex Custom Event - Dispatch An Event From Inside Two Nested Components And Receive
Apr 12, 2009
I am having trouble using a custom event in flex. I need to dispatch an event from inside two nested components and receive it in the main application file. The basic set up is a main application file importing a custom "gallery" component.
In my AIR application, I try to dispatch a custom event from a class to main window.This class is use to call httpservice. My goal is to send a custom window when the httpservice result is send.[code]...
I'm new to Flex.My question is how to dispatch event between components?As far as I know,Flex only bubbles event to itself or its parent. I'm in such a situation:
[Code]...
I want comp1 to dispatch an Event with parameters,according to the parameters some changes could be made to A and B in comp2.How could I get the event in comp2?I know Cairngorm could make a difference,but I don't want to use it right now.Could anyone give me a hand?
I got a question about event dispatching and dispatching in flex.
My goal is to pass an email address captured in one component (Comp1) and be passed to another (Comp2). These two components are navigator content of a viewstack. The custom event dispatched the email correctly from Comp1 but somehow could not reach Comp2. The application (Main) looks like :
I have an event listener for a custom event type. This custom event overrides the clone method as required.In this event listener I want to dispatch an instance of a different type of event... a different custom event instance altogether. It also overrides the clone method as required.The problem is I'm getting a type coercion error: TypeError: Error #1034: Type Coercion failed: ...I do not know what is trying to do the casting. My code is:
/* elsewhere in a method */ addEventListener(GestureEvent.GESTURE_SCALE, handlePinched); /* the event handler */
I have a repeater component with custom event. My repeater components fires custom event holding data. My need is to dispatch event so other repeater components can access data from dispatching component.
I am trying to get some code working from an example I came across. most of the functionality works but it is failing when it tries to dispatch a custom event. At the moment the code that is trying to dispatch the event is inside a class that handles amf remoting.the example has this line in it for the dispatch:
I am trying to dispatch a custom event from one flex module to another.The code which dispatch the event is as below Application.application.Destination.child.dispatchEvent( new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));
here AlgoEvent is a custom event.on the other side the module which catches and handles the event has this code:
public function sendParametersToChild(e:AlgoEvent):void {[ code]...
but when the statement Application.application.Destination.child.dispatchEvent(new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT)); is executed the debugger give the following run time exception:
TypeError: Error #1034: Type Coercion failed: cannot convert resources.events:: AlgoEvent@4182239 to resources.events.AlgoEvent.at flash.events::EventDispatcher/dispatchEventFunction()[code]...........
Is there a way to write a custom event that gets triggered when the user clicks outside of that custom component instance? Basically anywhere else in the main flex app.
This is NOT duplicate of my earlier post (its is slightly different)But this is similar issue with similar error but its not the same error The error I am getting now is below while dispatching the custom event from my custom component
TypeError: Error #1034: Type Coercion failed: cannot convert events::MapEvent@a74ab51 to flash.events.MouseEvent. dispatchEvent(new MapEvent(MapEvent.CLICKED_ON_MAP));
Note: The error in my earlier post is giving below error message
Type Coercion failed: cannot convert flash.events::Event@81ecb79 to com.events.ShopEvent
The difference here are two things, the earlier error is while converting flash event to custom event and now this one is while converting custom event to flash event and secondly, I have no clue why it is trying to convert to the mouseevent where I am just dispatching my custom event with proper listeners.
This doesn't work. creationComplete is not called until the repeater has finished instead of (as I expected) when the creation of the button is complete. I'm not sure how to accomplish this.
BTW - I also tried placing the creationComplete on the parent component to the repeater, but it would only be called the first time the component was rendered (the data inside the repeater sometimes changes) so that didn't work.
I have a problem understanding Events and event handling.I have a movieClipA wich contains several other movieClips (a1,A2,A3, etc..)MovieClipA is parent of movieClips (a1,A2,A3, etc..)
In movieClipA I use the following code: ... addEventListener ( "Pieter", pieterFnP ) ; dispatchEvent(new Event("Pieter"));[code]....
When I execute the application, function "pieterFnP" is fired, but "pieterFnC" NOT.
Followed it closely and still nothing! I dispatch the Event alright from the first .as file and it runs the function featEvent() but that's as far as it gets. (found this out using trace statements)
I have some problem with custom event dispatch, I have a main class call main.as, which will call in another class call something.as, when something.as is called it will dispatch an event. i have added an eventListener for that particular event, but it's not working.
I dispatch a custom event from an event dispatcher (following solution Inherited a class from EventDispatcher in Flash but custom event not received) and I add a listener in both dispatcher itself and in main. trace shows that only dispatcher receives this event not main. How to make main also receive the event?[code]
I hava a custom component and it contains a child icon. If I add a mouse-click event listener to both component(click-listener1) and icon(click-listener2), the event dispatched sequence is click-listener2, then click-listener1. I can understand it. But if I add a custom event to component (listener1), and mouse-click event to icon(listener2), when icon is clicked, the component will dispatch the custom event. In my test, the event dispatched sequence is listener1, then listener2. It doesn't match with event-bubbles rule.
In my opinion The custom event is dispatched in listener2, which triggers listener1. Why event flow sequence is not listener2, listener1?
In component.
icon.addEventListener(MouseEvent.CLICK, iconClickHandler); private function iconClickHandler(event:MouseEvent):void {
I have a boxer class that I would like to be able to dispatch a custom event out of at different times so the main timeline can pick it up and do something. It is at the end of different things. ie. movieclip finished playing. So far when I try to dispatchEvent it says I can't with error 1061.
I am trying to work with the EventDispatcher class to dispatch a custom event to stop a video from playing. The video plays inside a MovieClip with an attached class file called PlayerProfile. I want the video in the PlayerProfile MovieClip to stop playing when the user clicks on another MovieClip called ScrollBox. I'm getting no compile or runtime erros, but the code is not stopping the video. I have seen use of a public static constant to represent the custom event. Is that what I am missing here.
I am trying to understand event propagation in Flex framework and have a following doubt on it:
Scenario: I have a built-in component DropDownList on change of which I want to create a custom event refreshPreview and want to propagate it to a custom component PictureComponent.
In the custom component's mxml, I have added the Metadata directive as follows to register a refreshPreview event with the compiler
Layout Details: In my main mxml application I have laid out DropDownList and the custom component such that both are siblings (i.e. have a common indirect parent) e.g.
I am seeing that the refreshPreview event is not getting propagated to the custom component.
I doubt this is because the built-in component is a sibling of the target (where the event got generated) and not a parent. how to make refreshPreview event propagate to custom component?
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?
printableInvoice.addEventListener(batchGenerated, printableInvoice_batchGeneratedHandler);Results in this error: 1120: Access of undefined property batchGenerated. I have tried it as FlexEvent.batchGenerated and FlashEvent.batchGenerated.
The MetaData and function that dispatches the even in the component printableInvoice is all right. It I instantiate printableInvoice as an mxml component instead of via action-script it well let put a tag into the mxml line: batchGenerated="someFunction()
I made a custom loader to replace the urlLoader and even tried a replacement for the _loader using the same custom event.Works great for the first addEventListener:
Code: urlLoader.addEventListener(Event.COMPLETE, onSwfLoaded).But stops on the second addEventListener.If I just apply the custom event to the following...
Code: _loader.addEventListener(Event.COMPLETE, onLoaderInit); VERSUS
Code: _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderInit);it works just fine.As soon as I use it on the contentLoaderInfo line, it throws that type error cannot convert CustomEvent to Event error.I also double checked that my custom event listener was overriding clone()properly and it looks like it does.
Where, in this case, _list is an ArrayCollection object whose filter function depends on the showAll field to choose values.It turns out that this doesn't work, or at least gives a strong appearance of not working (what with the values in the list not changing and all). Is there a documented order of events for this, so that I can discover which events are dispatched in which order, and whether the binding value change will have fired the time the click event is dispatched? Alternately, can someone recommend a better way of doing this?