Event propagation in AS3/Flex 3.3

How to bubble up event from sub-app loaded into child application domain to the main app?
In other words main app loads sub app in child application domain.  Sub-app dispatches event
which is supposed to be listened in the main app. How to do it?
Regards,
_Ilya

What do you mean by sub-app .  Are you using modules ?  For regular situations you can set "bubbles" to true on the event.

Similar Messages

  • [svn:fx-trunk] 9215: Event Propagation bug fix

    Revision: 9215
    Author:   [email protected]
    Date:     2009-08-10 17:30:21 -0700 (Mon, 10 Aug 2009)
    Log Message:
    Event Propagation bug fix
    http://bugs.adobe.com/jira/browse/SDK-21044 - Spark Components should use event.preventDefault instead of event.stopPropagation
    Since keyboard are now cancellable, the Spark components should use event.preventDefault() / event.isDefaultPrevented()  instead of event.stopPropagation. I updated ButtonBar, RadioButton, and DropDownList to use preventDefault(). Also cleaned up Slider and Spinner to always assume the event is cancellable.
    QE notes: Add tests with these components inside of scrollable containers
    Doc notes: None
    Bugs: SDK-21044
    Reviewer: Hans
    Tests run: Slider, Spinner, RadioButton, ButtonBar, DropDownList
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-21044
        http://bugs.adobe.com/jira/browse/SDK-21044
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ButtonBar.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/RadioButton.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Spinner.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/DropDownCont roller.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/Slider.as

    error dateField not selecion date 27/11/2002 ?
    This is bug flex 3 ?
    thanks

  • Stopping Event Propagation

    Hi All,
    Am facing some issue in event propagation.
    I have a Application component with in which I have a link button. The Application has a mouseDown event listening for it and the link button has the click event listening for it.
    I have a requirement where in if i click on the link button i got to show an image and on again clicking on the link button hiding the image. Basically toggling the hide/show of image on click of the link button. This works fine as expected.
    Now I have mouseDown listening on the Application, where in If I click any where else in the Application again the Image show be hidden and only on click of Link button it should be shown.
    But since I have the mouseDown listening on the Application, whenever I click on the Link button the image is showing properly but then after that when I click the link button again to hide the image, then since two events are getting triggered  the Image is never getting hidden. It always shows up.
    THE FIX I NEED is that when i click on the link button, the parent event should be stopped from bubbling and hence only the Link Button's Click should be called and not the Application's mouseDown.. And in else other places, its fine to have the Application's mouseDown event called.
    I Tried event.stopPropagation () and event.stopImme()...but in vain.......... PLS HELP

    "Jimmy Jeeves" <[email protected]> wrote in
    message
    news:g8va3c$ak4$[email protected]..
    > Hi!
    >
    > I want to provide hotkey in my html webpage. (I am using
    >
    http://code.google.com/p/js-hotkeys/)
    > I also have a chat module in Flex. When I am typing some
    text in the flash
    > object, I don't want the hotkeys to be enabled.
    >
    > I tried to stop the propagation from the flash but it's
    not working.
    >
    > From what I know, the html events are propagated from
    the child to the
    > parents. So if I stop the event from my flash object it
    has to be ok,
    > right?
    >
    > See my example. If I display an Alert from the callback,
    it is displayed,
    > so
    > it works. Why the event is still propagated?
    >
    > Thanks
    >
    > public function reportKeyDown(event:KeyboardEvent):void
    > event.preventDefault();
    > event.stopPropagation();
    > }
    >
    > this.addEventListener(KeyboardEvent.KEY_DOWN,
    reportKeyDown);
    >
    I don't think you can preventDefault on key events. You could
    probably use
    ExternalInterface to tell the web page not to listen for the
    hot keys for a
    while, though.
    HTH;
    Amy

  • Event propagation API

    Hi,
    I recently started using Flex and read through the, very extensive and well written documentation. I read about the event propagation mechanism and was rather stunned that only Objects that have a parent-child relationship take part in event propagation. At first I couldn't believe it but trying to connect to objects that were at very different parts of the display list showed, that the events really do not get delivered! Wouldn't it be better to have a more general mechanism that does not care about the wherabouts of the components? I mean, what if I want to synchronize some model objects that are not even part of the display list with some UI Element they have a relationship with? The target phase doesn't work because its not the model that throws the event (of course!). Or do I miss something here?
    I was expecting a more subject-observer like pattern,  that allows me to connect whatever I want with whatever there is left. So, how do I do that. Do I have to right my own little event dispatching library (what would not be so difficult, but I would rather use something that has already proven its liability)? Can anybody recommend me a good API for that or tell me that I am dead wrong and missing something important?
    Regards,
    Benni

    Only DisplayObjects support bubble and capture propagation.  In a tree of
    regular Objects, as long as you attach a listener to the right object, you
    will be able to get its events.
    Bubble and capture are very dangerous as they break encapsulation.  We only
    use them for situations where the target is unpredictable like in mouse and
    keyboard interaction.  I would probably not use it in a data object tree.
    Maybe if you provide a more explicit example of what you are trying to
    accomplish and what you tried, folks on the forum can help.

  • Event propagation

    Hi,
    SAP has standard functionality of event propagation from FU to FB and vice versa.Now if I want to stop event propagation or event cascading functionality from FB to FU do I need to remove any code logic check in the extractor? Can you elaborate in details here.
    Secondly how does preprocessing functionality help in ENM functionality. What specific checks can eb brought about if w ewant to implement this functionality

    Hi Dipak,
    Extract the FU number as TOR_TEC tracking id from TM shown below
    FU EH TRacking ID table
    Tr.Code.Set
    Tracking id
    FU
    123456
    TRQ
    987563
    TO
    458796
    TOR_TEC
    123456
    Define the Tracking id Code Set(TOR_TEC) in Event reporting items under event message profile , configure only to particular internal event code which does not requires event propagation to FB.
    Above configuration supported only when the event posted via EM WebUI,
    you have to apply the same logic in BADI for interface event posting.
    Regards
    Sukumar

  • Extension Builder 3 and AS3/Flex

    Just a short question, to be sure:
    Extension Builder 3 will NOT support AS3/Flex but only "HTML5 Techniques"? In other words: Everything we/paid subcontractors have build can be thrown in to the trash an be build again to work with Creative Suite CC?

    Bingo! :-) Adobe knows how to piss of 3rd party developers.
    But it's actually not that simple. You can't just convert everything to HTML 5 and be "happy". If you want to support older creative suite versions (CS6 / CS5) you additionally have to build it in AS3 / FLEX since they don't support the new HTML 5 technology.
    Double strike, pain in the *** for all of us, at least for the next 2 years until everybody converted to the new CC philosophy.

  • Mobile IconItemRenderer - prevent event propagation

    Hello,
    I don't want anything to happen when an element is clicked or touched in a mobile itemRenderer extending IconItemRenderer.
    Isteand of overriding the drawBackground method and not listening for the change event, is there anyway of doing this faster, like preventing the event from propagating?
    Thank you.

    1. commitProperties seems fine
    2. I assume it would be faster since you avoid unnecessary drawBackground calls.  You might want to test to make sure.
    3. Correct, if you can't click on something it won't be able to fire a mouseDown event
    4. The mouseDown listener is added to the renderer in List.dataGroup_rendererAddHandler.  You could tweak it there, but that would require a subclass of List.  I typically find it easier to do from within the renderer via one of the two approaches I mentioned above especially when that changes based on the data in the renderer.
    5. The Flex SDK currently deals exclusively with mouse events.  See the "Mouse vs. Touch Events" section of this spec for more information: http://opensource.adobe.com/wiki/display/flexsdk/Mobile+List%2C+Scroller+and+Touch

  • Stopping an event propagation

    Hi!
    I want to provide hotkey in my html webpage. (I am using
    http://code.google.com/p/js-hotkeys/)
    I also have a chat module in Flex. When I am typing some text
    in the flash object, I don't want the hotkeys to be enabled.
    I tried to stop the propagation from the flash but it's not
    working.
    From what I know, the html events are propagated from the
    child to the parents. So if I stop the event from my flash object
    it has to be ok, right?
    See my example. If I display an Alert from the callback, it
    is displayed, so it works. Why the event is still propagated?
    Thanks

    "Jimmy Jeeves" <[email protected]> wrote in
    message
    news:g8va3c$ak4$[email protected]..
    > Hi!
    >
    > I want to provide hotkey in my html webpage. (I am using
    >
    http://code.google.com/p/js-hotkeys/)
    > I also have a chat module in Flex. When I am typing some
    text in the flash
    > object, I don't want the hotkeys to be enabled.
    >
    > I tried to stop the propagation from the flash but it's
    not working.
    >
    > From what I know, the html events are propagated from
    the child to the
    > parents. So if I stop the event from my flash object it
    has to be ok,
    > right?
    >
    > See my example. If I display an Alert from the callback,
    it is displayed,
    > so
    > it works. Why the event is still propagated?
    >
    > Thanks
    >
    > public function reportKeyDown(event:KeyboardEvent):void
    > event.preventDefault();
    > event.stopPropagation();
    > }
    >
    > this.addEventListener(KeyboardEvent.KEY_DOWN,
    reportKeyDown);
    >
    I don't think you can preventDefault on key events. You could
    probably use
    ExternalInterface to tell the web page not to listen for the
    hot keys for a
    while, though.
    HTH;
    Amy

  • Capture a "scrolling" event in spark List (Flex 4)

    after hours trying to find a scroller thumb drag event, i'm left stumped. Is ther any way to dispatch an event when the scrollbar of a List component is scrolling? or even better, to capture the scroll thumb dragStart and dragComplete events? thanks in advance -b

    You could detect when the scroll position of the viewport goes sufficiently below zero and then call your refresh logic from there.
    Here's an example of how to detect scroll position changes:
    http://stackoverflow.com/questions/4390725/flex-4-scroller/4425091#4425091

  • Event propagation in mediumweight components

    Hi,
    There's an article "Mixing heavy and light components":
    http://java.sun.com/products/jfc/tsc/articles/mixing/
    It explains mouse event handling:
    "Mouse events on a lightweight component fall through to its parent; mouse events on a heavyweight component do not fall through to its parent. "
    What about mediumweight components? Are mediumweight components receiving mouse events like lightweight or like heavyweight components?
    Is it possible to infer how the mouse events are propagated just by using JComponent.isLightweightComponent()?
    Kari

    What do you mean by sub-app .  Are you using modules ?  For regular situations you can set "bubbles" to true on the event.

  • Event Propagation again. Sorry

    Hi guys, I vave a pretty simple app to test how the propagation works.I do not undestand, why the propagation on the stage 3 (bubbling) works in the oppsit way than it should work.
    Here is my code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                xmlns:view="view.*" initialize="init()">
    <mx:Script>
    <![CDATA[
         import mx.controls.Label;
         import mx.events.FlexEvent;
         import mx.controls.Button;
         import mx.controls.Alert;
         import flash.events.TextEvent;
         private function init():void {
              this.addEventListener(MouseEvent.CLICK, handleTestEvent);
              vBox2.addEventListener(MouseEvent.CLICK, handleTestEvent2);
              vBox1.addEventListener(MouseEvent.CLICK, handleTestEvent1);
         private function handleTestEvent2(event:MouseEvent):void {
              Alert.show("This is VBox2  " + event.eventPhase );
         private function handleTestEvent1(event:MouseEvent):void {
              Alert.show("This is VBox1  " + event.eventPhase);
         private function handleTestEvent(event:MouseEvent):void {
              Alert.show("This is Application  " + event.eventPhase);
    ]]>
         </mx:Script>
              <mx:VBox id="vBox2">
                   <mx:VBox id="vBox1">
                        <mx:Button id="testButton" label="Click Me" />
                   </mx:VBox>
              </mx:VBox>
         </mx:Application>
    So, when I run this application, the first popup I see is: This is Application 3. Then: This is VBox2 3  and the last one: This is VBox1 3. But as I understud the order should be: This is VBox1 3,  This is VBox2 3,  This is Application 3.
    Could some body explain what's wrong?
    Thanks.

    The Alert boxes sit on the top of the display.
    When you get the first alert, it appears over the content.
    When the second happens it sits over the first alert.
    Then the third happens and sits over the second.
    So, when you see the third alert, it looks like there is only one box, but there are two underneath - hidden.
    You dismiss the third alert and see the second.
    You dismiss the second and see the first.
    It looks like the order is reversed, but in fact the order is correct and they have just popped up over each other. It feels that dismissing the third alert causes the second alert to popup, but it doesn't - it was there all along.
    Alert isn't synchronous.

  • Event propagation and inheritance

    Hi,
    I have a button inheriting from another. In the ancester I have a CLICK event handler registered.I have another CLICK event handler in the descendent button. In the descendent I want to handle the CLICK event combined with the CTRL key. Without the CTRL key I want the the ancester event handler to do it's work. I tried different combinations of StopPropagation(), StopImmediatePropagation priorities, etc...with no satisfactory result. Sometimes both event handlers are triggered, sometimes only the event handler for the descendent is triggered. What would be the way to do this. Thanks in advance.

    Thanks Natasha,
    I solved my problem by overriding the click event handler in the descendent like:
    override protected function clickHandler(event:MouseEvent):void {
         if (event.ctrlKey) {
              ...do the stuff in case of CTRL-key held
         } else {
              // Do ancestor work for normal click         
              super.dispatchEvent(event)
    So...no need for stopping propagation of the event

  • Event propagation from child application to main application

    Hi,
          I am using SWFLoader to load third party component into our main application.we are trying to create annotation feature on top of child application.for that main application needs to receive events e.g. mouse events from child application.can anyone suggest whether this is possible ?
          I found pdf doc from help of SWFLoader component on flex developmenent center.It has an example in which child application uses SystemManager to register event listner for main application.so is it that we need to register listener from child application so main application receive events ?
       Thanks in advance.
    Thanks and regards,
    Rakesh Parmar

    If you examine the urls and the domains are the same then you don't have a cross-domain problem, but then your symptoms remain unexplained.
    Note that Flash just checks the text of the domain/sub-domain so http://localhost/ is different from http://10.0.0.127/ or whatever its IP equivalent is.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Sharedobject.connect() fails .. AS3/Flex

    But about every 6th time the app starts, the
    sharedobject.connect(nc) fails to connect. I can see it fails
    because it does not sync, as well, it does not register on the
    server. If have a try, catch on the connect and it shows nothing.
    What should I be catching???
    I'm setting it up like this: My question, what am I missing
    to catch an error when the SharedObject.connect() fails?
    In AS2.0, the connect would return a true or false. In AS3,
    which I'm using, it returns null.
    nc.addEventListener(NetStatusEvent.NET_STATUS, onStatus );
    nc.connect(..... );
    public function onStatus( event:NetStatusEvent ):void{
    var info = event.info;
    switch( event.info.code ) {
    case "NetConnection.Connect.Success":
    connectSO();
    break;
    public function connectSO() {
    try {
    this.so = SharedObject.getRemote( this.sopath + "xxx",
    this.nc.uri, true);
    this.so.addEventListener(SyncEvent.SYNC, onSync);
    this.so.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
    onAsyncError );
    this.so.addEventListener(NetStatusEvent.NET_STATUS,
    onNetStatus);
    this.so.connect( m_nc );
    this.so.client = this;
    } catch (err:Error)
    //put these for the client
    public function asyncError( evt:Object) {
    public function netStatus( evt:Object) {
    public function sync( evt:Object) {
    }

    Well I found an error in FMS where the client is trying to
    access the sharedobject before the client.readAccess and
    client.writeAccess is set serverside. This is raising a tiny error
    in FMS, and the SharedObject is silently not connecting client
    side.
    I am using components server side. When the client connects,
    and is authenticated and the client connection was accepted and
    then the client was added to all loaded components. The .addClient
    in the component is where the read/write access is granted to the
    client. But on the client side,it was trying to sync (i.e read) the
    sharedobject before the .addClient is called. It was a race
    condition.
    So I changed the order to authenticate, then add the client
    to the server-side components and then do the
    application.acceptConnection(client). Fortunately that didn't break
    anything and logically makes sense.
    But.. my question still stands.. how do I capture such an
    error client side? In general, it would sure be nice to know when a
    connection attempt fails or is rejected.

  • Help with understanding key event propagation

    Hello,
    I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
    (1) Components have 3 input maps which map keys to actions
    one for when they are the focused component
    one for when they are an ancestor of the focused component
    one for when they are in the same window as the focused component
    (2) Components have a single action map which contains actions to be fired by key events
    (3) Key events go to the currently focused component
    (4) Key events are consumed by the first matching action that is found
    (5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
    (6) The first matching action handles the event which does not propagate further
    I have a test class (source below) and I obtained the following console output:
    Printing keyboard map for Cancel button
    Level 0
    Key: pressed C
    Key: released SPACE
    Key: pressed SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Save button
    Level 0
    Key: pressed SPACE
    Key: released SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Main panel
    Event: cancel // typed SPACE with Cancel button having focus
    Event: save // typed SPACE with Save button having focus
    Event: panel // typed 'C' with panel having focus
    Event: panel // typed 'C' with Cancel button having focus
    Event: panel // typed 'C' with Save button having focus
    I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
    (1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
    (2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
    (3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
    (4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
    Any help appreciated. The source is:
    import javax.swing.*;
    public class FocusTest extends JFrame {
         public FocusTest ()     {
              initComponents();
              setTitle ("FocusTest");
              setLocationRelativeTo (null);
              setSize(325, 160);
              setVisible (true);
         public static void main (String[] args) {
              new FocusTest();
    private void initComponents()
         JPanel panTop = new JPanel();
              panTop.setBackground (java.awt.Color.RED);
    JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
    lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
    lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
              panTop.add (lblBanner);
              JPanel panMain = new JPanel ();
              JLabel lblKey = new JLabel ("Key:");
              lblKey.setFocusable (true);
              JLabel lblValue = new JLabel ("Value:");
    JTextField tfKey = new JTextField(20);
    JTextField tfValue = new JTextField(20);
    JButton btnCancel = new JButton (createAction("cancel"));     // Add a cancel action.
    JButton btnSave = new JButton (createAction("save"));          // Add a sve action.
              panMain.add (lblKey);
              panMain.add (tfKey);
              panMain.add (lblValue);
              panMain.add (tfValue);
              panMain.add (btnCancel);
              panMain.add (btnSave);
              add (panTop, java.awt.BorderLayout.NORTH);
              add (panMain, java.awt.BorderLayout.CENTER);
    setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // Add an action to the panel for the C key.
              panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
              panMain.getActionMap ().put ("panel", createAction("panel"));
              // FAILS ???
              // Add an empty action to the Cancel button to block the underlying panel C key action.
    btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
    // Print out the input map contents for the Cancel and Save buttons.
    System.out.println ("\nPrinting keyboard map for Cancel button");
    printInputMaps (btnCancel);
    System.out.println ("\nPrinting keyboard map for Save button");
    printInputMaps (btnSave);
              // FAILS NullPointer because the map contents are null ???
    System.out.println ("\nPrinting keyboard map for Main panel");
    // printInputMaps (panMain);
    private AbstractAction createAction (final String actionName) {
         return new AbstractAction (actionName) {
              public void actionPerformed (java.awt.event.ActionEvent evt) {
                   System.out.println ("Event: " + actionName);
    private void printInputMaps (JComponent comp) {
         InputMap map = comp.getInputMap();
         printInputMap (map, 0);
    private void printInputMap (InputMap map, int level) {
         System.out.println ("Level " + level);
         InputMap parent = map.getParent();
         Object[] keys = map.allKeys();
         for (Object key : keys) {
              if (key.equals (parent)) {
                   continue;
              System.out.println ("Key: " + key);
         if (parent != null) {
              level++;
              printInputMap (parent, level);
    Thanks,
    Tim Mowlem

    Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
    2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
    In your case you only added a single binding.
    3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
    4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent.

Maybe you are looking for

  • JDeveloper's compiled JSP location in a .war file

    When I choose to build a .war file in JDeveloper 10.1.2 that contains the .JSP files, it sticks the compiled jsps in WEB-INF/classes/.jsps. To get the app server to properly recognize the precompiled JSPs, they need to be located in the WEB-INF/class

  • Synch/Asynch with out BPM

    Hi All, I have a HTTP to webservice scenario currently running in production , i.e ., From the HTTP Application user sends a request to XI . XI makes a SOAP call and sends the request back to HTTP Application .              now I have a new requireme

  • Buying iPhone 5 from third party retailer w/ unlimited data

    I ordered an iPhone 5 in-store on the 21st since I couldn't find a way to pre-order and keep my unlimited data, even though I was paying full retail. My ship date isn't until October 19th, and that's a long time to wait. But I did find a local Radios

  • ITunes won't play songs after update

    I updated to 11.1.4 today. I had to restart Apple Mobile Devices and Bonjour to get my pc to see my iPhone and my Time Capsule respectively. However, if I open iTunes and click on a song to play, it stays stuck at 0:00 and won't play. If I move the s

  • Cannot PXE boot 32-bit and 64-bit hardware at the same time

    I have ConfMgr 2012 R2, but this same problem occured also with SP1. The main issue is, that 32-bit hardware clients are pulling 64-bit boot images. If I remove 64bit boot image from DP, everything works fine, but then, 64-bit hardware will stay pend