AS :: Flex - Handle Custom Event In Parent Component?

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


Similar Posts:


Flex :: 4 - Multiple Instances Of A Custom Component Listening The Same Event Of A Parent

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

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

Flex :: Dispatching Custom Event From A Custom Component?

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

Flex :: Disptaching Custom Event From Custom Component?

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

Flex :: Propagating Event From A Built-in Component To A Custom Event?

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

Flex :: Event In A Custom Component?

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

Actionscript 3 :: Handle A Custom Event In It?

Oct 28, 2010

I've created an Event Handler/Listener like so[code]...

Access of possibly undefined property data through a reference with static type flash.events:Event.

View 2 Replies

FLEX :: Flash - Component Not Receiving It's Own Custom Event?

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

Actionscript 3 :: Flex 3 Event Propagation On A Composite Custom Component?

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

Flex :: Dispatching Custom Event From Repeater Component And Listen Event In Other Repeater Components

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

Actionscript 3 :: Handle An Event In A File That Was Dispatched From A Mobile Spark Component

Jan 11, 2012

I have an mxml file called HomeView.mxml in a mobile app built using Flash Builder 4.6. In that HomeView.mxml I have an HSlider, which is dispatching events when the thumb is moved. What I'm trying to do is to listen for that valueCommit event in an .as file elsewhere in the project.

Whenever the thumb moves, an event is dispatched in HomeView.mxml:

hSlider.dispatchEvent(new FlexEvent("valueCommit", true));

I can handle that event in HomeView.mxm, but not in an .as class called view.as

In view.as I import the FlexEvent and I then have, in addedToStageHandler:

stage.addEventListener(FlexEvent.VALUE_COMMIT, commitHandler);

Then there's a simple Handler:

private function commitHandler(e:FlexEvent):void
{
trace("committed!");
}

But this code never runs. I do have a handler in the HomeView.mxml file which handles the event, but for other reasons I need to handle it in view.as as well.

View 1 Replies

Actionscript 3 :: Propagate Custom Event To Parent?

Oct 3, 2010

I have got a custom event set up (see below), but when I listen for the event in my main class, and it gets dispatched from the child class, it never gets captured.

TRIED:

this.b.addEventHandler(GameLaunchEvent.GAME_LAUNCH_EVENT, this.eventHandler)
package com.thom.events
{

[Code].....

View 2 Replies

ActionScript 3.0 :: Custom Event From Parent To Child?

Sep 22, 2010

I have a simple 2 class game Im working on. It has a document class (BubbleBuster.AS) and a Bubble class (Bubble.AS). In the doc class I made a container sprite called bubbleContainer. I add bubbles (instances of Bubble.AS) to the bubbleContainer. When the game is over I fire a custom event in the bubbleContainer from the doc class like so:Code:bubbleContainer.dispatchEvent(new Event("gameOver"));Now I want to listen for this event in the Bubble children so I can kill tweens and remove things. So in the Bubble.AS I have:Code:parent.addEventListener("gameOver", gameOver);this compiles fine. But as soon the 1st Bubble is added to bubbleContainer I get this error (and no bubble appears):TypeError: Error #1009: Cannot access a property or method of a null object reference.

at Bubble/init()
at Bubble()
at BubbleBuster/addBubble()

[code].....

View 6 Replies

ActionScript 3.0 :: Custom Event From EventDispatcher To Sprite's Parent?

Apr 1, 2010

I have a sprite A which has a child, sprite B.Sprite B has a variable, instance of class C which only extends EventDispatcherIn class C, I dispatch a custom Event. The eventlistener in sprite B reacts on the event.The same eventlistener in class A doesn't respond.If I dispatch the same custom event in the eventhandler in class / sprite B, this event is seen in class / sprite A.Is there a difference in events going through the displaylist and those who are from an EventDispatcher?

View 6 Replies

ActionScript 3.0 :: Dispatching A Custom Event From Parent Swf To Child Swf

May 8, 2010

I'm building an all flash site, where one .swf acts as the parent, and other external child .swf's are loaded in using .xml. The "Child.swf's" are a mixture of timeline animations, and coded swf's, and the problem I'm having is that they immediately start playing as soon as they are loaded. I've not been able to find any straightforward "child.start() or child.stop()" solutions, so I assume it's more involved than that.

I thought it might be a good idea if I could dispatch events from the parent swf that will set them going. I'm using the sharedEvents method to communicate in the reverse direction (child to parent), but I don't believe it can be used from parent to child (Please correct me if I'm wrong!) I know I could go to each child and put "stop();" in the first frame, but how do I start it again? I would also prefer it if not all the child .swf's started immediately, but to wait until others have completed their routines. Again the way I see it is to dispatch an event from the parent .swf as soon as I'm ready to set them going.

View 6 Replies

Actionscript 3 :: Redispatch A Custom Event To Another Class (not A Parent) In Flash?

Apr 9, 2011

I cannot bubble the event because I want to send to another class that is not even a movieclip but a simple class. So I transform previous source code here Is it impossible with Flash to get the Instance Creator ? for

[Code]...

View 2 Replies

ActionScript 3.0 :: Shared Custom Event Between Parent And Child Swf On Different Domains?

Aug 23, 2010

I have two swfs for a project, I had both of them to dispatch events to each other. Parent loads child and is listening for the compete load event. Once that event is dispatched to the child - the child dispatches a start event back to the parent. I got this working by copying the ModelEvent(my custom event) in each of the flash builder actionscript projects in the exact file structure ( i think i was cheating it there, since )

It broke when I put the swf on separate domains, so I'm thinking I'm missing something to share the custom event class between two swfs.

[Code]...

View 9 Replies

Actionscript 3 :: Propagate Custom Event To Parent Swf From Element Inside Child Swf

Jul 19, 2011

I have two swf file, A.swf and B.swf, each with its Document Class: B.swf is loaded in a MovieClip of A.swf. When loaded, B.swf creates an instance of CSDragger (it is a library object with its class extending MovieClip) and sets an ID property of this instance to a certain value. When this dragger is dropped by the user upon a MovieClip it sends a custom event containing the value of ID too. The custom event regularly reaches B.swf but never reaches A.swf. Aside from refactoring the CSDragger class (eg moving its handleDrop method in the B.swf document class), is there any way for the event to reach A.swf? I know I can intercept it and dispatch another event, but I was looking for a different solution (if any).[code]

View 1 Replies

Actionscript 3 :: Flex 4: Window System Development - Can't Use The PopUpManager To Handle Custom Components

Aug 24, 2010

My application will need some windows but I can't use the popUpManager to handle custom components so I'm thinking to implement a new window system. But I still don't know how to merge it with my custom components.

[Code]....

View 1 Replies

Flex :: Put Custom Code In A Custom Component In Flash Builder?

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

Actionscript 3 :: Handle Event For Nonvisual Objects In Flex?

Nov 7, 2011

I am trying to perform two way binding e.g I have a button (out of many controls), on its selection, I am showing the values of its diff properties(like height, width etc) in some textinput. This one way process works fine.But the reverse process doesn't work. i.e When I select some button, and try to change its dimension by entering some value in height, width textinputs, the dimension are not changed.

private void Form1_Load(object sender, System.EventArgs e)
{
//Create some data and bind it to the grid

[code].....

View 1 Replies

Flex :: Make A Custom Component Or Extend The List Component For A 2D Top Down View MAP ?

Nov 11, 2010

I'm building a top view 2D map, that it's objects are stored on the server.The kind of objects are 10 and might be a photo, label, button, lists, mix of them or labels with tooltips.The component must request the "areas" that are missing on screen.An area is 1000x1000 px and is cached in flex.To move in the map, will be like in google maps (drag-and-drop).I should be able to have another list and move objects from one to another using drag-an-drop on objects. Ex.: I grab an objects from a list and I move it on this map, I release the mouse button and the item is placed there.Now the problem is: I build a custom component for this trying to emulate the item renderer for performance and recyclage, implement drag-and-drop on objects and request the areas that are missing?

or

I extend the List component from spark and I add some features as multiple kind of itemrenderers and use recycle on them. Of course it must be able to request the missing areas on the screen and cache it's data.Maybe create a custom layout is needed too.What I need is something that must be really fluid, so the lighter this component is, the better.

UPDATE: *There will be not any object over another.

*I will not use hitTest on bitmaps because all bitmaps are wrapped in another component,as they,for now are itemrenderers.

Anyway I already begin to do this using a class that extends the SkinnableDataContainer and a custom layout. As the layout is not like a grid, is sparse, random items at diferent points(x, y).How to get the localX and localY, relative to item renderer and not to the Spark List, from a DragEvent in Flex 4?

View 1 Replies

Flex :: Define Custom 'contentGroups' In A Custom Flex 4 Component?

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

Actionscript 3 :: Flex 4.5 Not Listening To Custom Event Dispatched In Custom Class?

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

Flex :: Event Flows For Built-in Event And Custom Event

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

Actionscript 3 :: Why Won't Visual Elements Display Inside Custom Component Extended From Another Custom Component

Sep 6, 2011

I created a custom MXML component, TurboContent, that extends the NavigatorContent class:

<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">

[Code].....

In this case, the 'myButton' component never shows up, but all the elements of the base component do (3 buttons and a datagrid).

View 2 Replies

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.

[Code]..

View 1 Replies

ActionScript 3.0 :: Listening For Custom Event Dispatched From Parent Object In Child Object?

May 25, 2010

I want to listen for a custom event dispatched from the document class in a custom subclass. For example, let's say in the document class I have:

ActionScript Code:[code]....

So that the subclass will trace 'Event from document class received' when the 'customEvent' event from the document class is listened by the eventlistener. However, the output is only 'customEvent dispatched', meaning it wasn't heard in the subclass.

View 7 Replies

ActionScript 3.0 :: Parent Movieclip Doesn't Listen To Custom Event In The Child Movieclip?

Oct 24, 2010

I have movieclip which contains child movieclip. when child movie clip finish to play i want to run a function in a parent movieclip. so I made a custom event dispatcher in the first frame of the child movieclip:

[Code]...

View 4 Replies







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