Actionscript 3 :: Flex 4 Disptaching Custom Event From Custom Component (why Flex Converting Custom Event To Mouseevent)?
Mar 2, 2012
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 is my custome event
package events
{
import flash.events.Event;
import ui.map.MapElement;
[code]...
View 1 Replies
Similar Posts:
Feb 16, 2012
This is similar to the question asked here. I am dispatching custom event "ShopEvent" but i am getting error "Type Coercion failed: cannot convert flash.events::Event@81ecb79 to com.events.ShopEvent"Note: Error is thrown from the parent custom component (3rd code snippet), I have added more details thereThis is my custom event. See the first constant, I copy pasted the event name in custom components.
package com.events
{
import flash.events.Event;
[code]......
View 3 Replies
Sep 8, 2011
I have a custom Flex 4.5 component (to be used in a List) -
Game.mxml (represents a clickable playing table in a card game):
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer [code].......
But I never see the "game clicked: " trace. Does anybody please know why? I'm probably missing something minor, because I can see the "Clicked: 8946" trace.
View 3 Replies
Jan 27, 2012
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
<fx:Metadata>
[Event(name="refreshPreview", type="flash.events.Event")]
</fx:Metadata>
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.
<s:Group id="contentGroup">
<s:Group id="formGroup">
<s:Form x="11"
[Code]....
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?
View 1 Replies
Nov 4, 2011
I have the following situation:I have an event handler, that displays small messages in my application's statusbar.These messages get passes through by dispatching events from custom components.A simple message could be like "HTTP Error" or so.Now, the main event listener, in the main application file, listens to the event dispatched by any custom component,but seems to refuse listening to events dispatched by custom AS classes.Here is my code for the custom event:
package main.events
{
import flash.events.Event;[code]..
So to sum it all up:
- The event listener listens to the custom event dispatched by any custom component.
- The event listener does not listen to the custom event duspatched by an AS class.
Those who wonder, the event really gets dispatched, that's why I added a trace call.
View 2 Replies
Sep 11, 2010
I'm just getting started with custom events in a custom component. And I don't quite have the hang of it, yet. I've got a component with a button in it. When it's clicked, I want to call a function in the main app.
Custom Component:
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" >
[code].....
View 1 Replies
Feb 6, 2010
I defined a simple event class:
public class NewMoveEvent extends Event
{
public function NewMoveEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=true)
[code].....
View 1 Replies
May 10, 2011
I made a movieclip in flash that dispatches a custom event: MyEvent.THE_TYPE = "the_type"in flex I have: <local:my_flash_mc the_type="do_something()"however, this is not working.in flash, my event bubbles is set to true. everything works fine in flash.in flex I am NOT using:
<fx:Metadata>
[Event(name="the_type", type="...")]
</fx:Metadata>
[code]....
View 3 Replies
Dec 28, 2009
Is there a point of creating custom event class if i dont need to pass custom property with that event?
View 3 Replies
Jul 24, 2009
I have a custom component made up of a selectable control (radio button)and a text input. I want to perform some logic in response to the change events from both of those controls, but after that I want anything that is registered on the composite component's change handler to have a change to handle the events as well. The problem is, when I re-dispatch the events the event target has changed to my custom component, losing the originating event's target.
Here's my custom component:
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{listItem.@text}" data="{listItem.@level.toString()}">
<mx:Script>
[code].....
In the event handler that receives change events from this component, I see that event.target is an instance of SpecifyRadioButton, not the TextInput or RadioButton, as I'd expect. How should I propagate the event to get what I want here?
Getting event [Event type="change" bubbles=false cancelable=false eventPhase=2]
from question0.tabSurvey.questionForm.questionContainer.Single94.VBox95.SpecifyRadioButton111
View 2 Replies
May 4, 2011
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.
Edit: Added whole stuff here.
<!-- AttributeMapping.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
[Code].....
View 1 Replies
Jan 28, 2011
In short: I need an event listener in a custom component so all its instances (without editing them) react at the same time, fired by a dispatched event in its parent container. In detail: I have a custom component with Tab navigator. (The tabs are intended to show different preferences for different Languages.) I have a button bar with buttons for all the languages. There are a lot of instances of the custom component.
I want to click in a button of the languages bar and get ALL the instances switched to the same tab (the custom component contains the logic to change the tab). I can do it by adding the event listener for EACH INSTANCE of the custom component, so it calls an internal function that changes the tab. But it seems to be very coupled, isn't it? I wonder if it can be done in the master CLASS of the component, so it listen for events in its parent container, whichever it is. In my mind this code shoud work, but it doesn't (obviously ill'use a custom event to pass the new language value): this.parent.addEventListener("lang_change", this.change_tab); This way I can just drop an instance of the component, and see it working for itself.
View 2 Replies
Aug 22, 2011
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
{
[Code].....
View 1 Replies
Dec 11, 2010
In the main file, I would write[code]...
But if I want the component to have that behaviour innately, where do I write it in the mybutton mxml file to have it reference itself?[code]...
View 2 Replies
Sep 25, 2009
How to take an existing custom component in Flex and convert it into a module? EDIT: What should be done in the mxml where this custom component is used? Should it be replaced with a to load the module? If yes, how to deal with code that uses instances of the components?
View 2 Replies
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.
[Code]..
View 1 Replies
Apr 20, 2010
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()
View 2 Replies
May 12, 2010
The spark panel component for example can be written like this
<Panel title="Skinny">
<child components ... />
<controlBarGroup>
<child control bar components ... />
</controlBarGroup>
[Code]...
The motivation here is that I can now create a couple different skin files to change the look and layout of those subgroups. Reading source of the spark panel, there are some calls within the mx_internal namespace such as getMXMLContent() which is a method of the spark group component, but which I have no access to.
Does the description above make sense? How can I create custom 'contentGroups' in my custom Flex4 component that can use nested mxml child components? Should I approach this a different way?
View 2 Replies
Aug 25, 2009
i am a bit embarassed to ask this, but i do this so much i have to ask. Occasionally, i need to pass/handle custom events on the fly. Rather than creating a whole custom event class, i will just do something like
Code:
myObject.dispatchEvent(new Event('thisCustomEvent'));
//and then handle it later
[code]....
View 12 Replies
May 14, 2011
how to dispatch custom event in flex in my main mxml file i have put this code to dispatch this function
[Code]....
i want to ask what i am missing why my customevents not working
View 2 Replies
Oct 10, 2010
I got a question about event dispatching in flex.my goal is to get a custom event loaded up with some data and than bubble up to the eventlistener. my main application has and AMF service request inside which calls an service class. that class is supposed to dispatch an event when the AMF service request returns a result or fault and the main application is listening for that event.so inside my mainapp i add and listener like this:[code]
However, this event never reaches the main application. Looking closely to it with the debugger, i found out that when the event is dispatched the listeners property of it is set to null.
View 5 Replies
Jun 23, 2011
I'm in a Flex Mobile application project. I need to dispatch an event to the lexGlobals.topLevelApplication and it has to contain a custom message. I'm trying to make an object and dispatch it like this:
//create the event Object
var receivedObjMsg:Object = new Object();
receivedObjMsg.name = "receivedMessage";
receivedObjMsg.message = messagevarhere;
[Code]...
View 2 Replies
Feb 15, 2012
I'm trying to dispatch a custom event from a custom ItemRenderer. This is my custom event
package events {
import customClass.Product;
import flash.events.Event;
public class CopyProductEvent extends Event {
public static const COPY_PRODUCT:String = "COPY_PRODUCT";
public var picked:Prodotti;
[Code] .....
The event from the function is dispatched correctly... I can't intercept it..
View 1 Replies
Jan 25, 2009
I created a new CustomEvents object which I want to use to let the main class located in .mxml file to know about an event which had finished it's work in Crop class. However when I dispatch a CustomEvent from Crop class I can not catch it in my main .mxml file's class.
CustomEvents class
Code:
package actions
{
import flash.events.Event;
public class CustomEvents extends Event
[code]....
View 4 Replies
Jul 18, 2009
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.
View 2 Replies
May 25, 2010
I have 2 custom components, which have their own nesting hierarchy ... One is container for another. I have to "familiarize them" with each other. The way I'm trying to achieve that is using global events (one side is firing and the other one is catching):
Application.application.addEventListener("Hello", function (data:Event):void{
// .. some actions
});
[Code]...
Then should be created the connection between container and it's child.
BUT, the only thing I could acheive is passing a reference to the Container in the DynamicEvent. Is there any chance that I could access the child at the event-handler function.
View 3 Replies
Jun 17, 2010
I have a Renderer:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" [code].............
View 5 Replies
May 2, 2011
I'm having the following problem: I've implemented a custom headRenderer for my DataGridColumn. The idea is to have a dropdown menu when clicked on the column header. The problem is I don't know how to add a listener or pass a variable to the renderer since the renderer class is instantiated by the ClassFactory.
The renderer class:
<?xml version="1.0"?>
<!-- itemRenderersdataGridmyComponentsRendererDGHeader.mxml -->
<mx:HBox xmlns:mx="library://ns.adobe.com/flex/mx"
[Code].....
View 1 Replies
May 27, 2011
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 :
<fx:Script>
<![CDATA[
import events.LoginEventComplete;
[Code].....
View 2 Replies
Sep 14, 2011
I have an object being passed between flash and flex using the a custom event. I am importing a library in flex containing a copy of the object's class. The classes are identical. But when I attempt to access the object in flex I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert com.cackleberries.data.api::ApiObject$ to com.cackleberries.data.api.ApiObject.
This function is passed into flash as a callback from AIR / flex
public function airEventHandler(type:String, data:Object):void {
switch(type) {
case "air_api_call":
if(data) {
if(data.hasOwnProperty("apiObject"))
[Code] .....
I am getting the error when I pass the apiobject to serverApi.makeApiCall. That function takes a ApiObject as its parameter. Initially, the data object is created with with the apiObject key with a ApiObject as the value (done in flash).
View 1 Replies