2 Replies Latest reply on Jul 1, 2009 9:00 AM by flexiom

    Event.CHANGE - bubbles or not?

    flexiom

       

      I have a little  Event propagation question;

      Im using Fbuilder 3 testversion on XP and have flash player 10 installed.

      Flax 3 API(at least that from http://livedocs.adobe.com/flex/3/langref/) says that the  flash.events.Event.CHANGE bubbles

      butt wenn i debug the e:Event in the rb_selection function my debugger says it is does NOT.

      So what now? Can anyone please explain this?

       

       

       

      Following code (init is called on app's creationComplete

       

       

      private function init():void {

          male.addEventListener(Event.CHANGE,rb_selection);

          female.addEventListener(Event.CHANGE,rb_selection); 

      }

      private function rb_selection(e:Event):void

      {

          e;   

      }//break point hier

                       

      ]]>

      </mx:Script>

       

       

      <mx:VBox id="vb">

      <mx:RadioButton groupName="gender"

                                          id="male"

                                          label="male"/>

      <mx:RadioButton groupName="gender"

                                          id="female"

                                          label="female"/>

      </mx:VBox>

      </mx:Application>

       

        • 1. Re: Event.CHANGE - bubbles or not?
          cfchitchat Level 1

          the bubbling phase, comprises all of the nodes from the target node's parent to the root node.

          U just change traget nodes. in tht case bubles not true...

          dispatch an event in Vbox then clickthe radiobuttion bubbling phase will come ..just try

          Just dispatch an event fron VBOX .......

          Just read this http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html#215364

          Plz try this

           

           

          <mx:Script>
              <![CDATA[

           

                     private function rb_selection(e:Event):void

              {
                 Alert.show("Phase: " + e.eventPhase + "\n" +
                          "Current Target: " + e.currentTarget.id);
                 e; 
              }


              ]]>
          </mx:Script>   
               

          ]]>

          <mx:VBox id="vb"  mouseDown="rb_selection(event)">

          <mx:RadioButton groupName="gender"

                                              id="male"

                                              label="male"/>

          <mx:RadioButton groupName="gender"

                                              id="female"

                                              label="female"/>

          </mx:VBox>

          </mx:Application>

          • 2. Re: Event.CHANGE - bubbles or not?
            flexiom Level 1

            Txn for help but i doesnt work for me. What I wont to do ist following. See the Code for main-app and  component:

             

            main-app

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                            xmlns:local="*"
                            layout="vertical"
                            applicationComplete="appComplete()">

             


                <mx:Script>
                    <![CDATA[
                        import mx.events.ItemClickEvent;
                        private function appComplete():void
                        {
                            comp.addEventListener(ItemClickEvent.ITEM_CLICK, ic_comp);
                        }
                        private function ic_comp(e:ItemClickEvent):void{
                            trace(e.toString())
                            // HOW TO KNOW HIER WHICH ADIOBUTTON WAS CLICKED???           
                        }
                    ]]>
                </mx:Script>
                <local:_RadioButtonGroup_comp id="comp"/>

             

            </mx:Application>

             

            component

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
                      layout="vertical"
                      width="300"
                      height="200"
                      creationComplete="creationCompleteHandler()">
                <mx:Script>
                    <![CDATA[
                        import mx.events.*;
                        private function creationCompleteHandler():void
                        {
                            rbg.addEventListener(ItemClickEvent.ITEM_CLICK, ic);
                        }

             

                        private function ic(e:ItemClickEvent):void
                        {
                            trace(e.target.selectedValue); //HIER I KNOW
                            dispatchEvent(new ItemClickEvent(e.type, true));
                        }
                    ]]>
                </mx:Script>
                <mx:RadioButtonGroup id="rbg"/>
                <mx:RadioButton groupName="rbg"
                                id="male"
                                label="male"/>
                <mx:RadioButton groupName="rbg"
                                id="female"
                                label="female"/>
            </mx:Panel>

             

             

            I can’t catch the dispached event from my component in my main-app.

            In main app r target and currentTarget the same? So it simply doesn’t work. I expected to se the target as the radioButton,  but I see my component – probably because I redespached it ???

             

            I found the solution is to define own event class, and then hoock the “old”-target as extra property wenn redespaching the event to the main app. That works.

             

            But I ask my self – can it be the only way, Do I really have to write own event-class for every single Event that doesn’t bubble per default???

            I mean, I understend the point of custom event-classes, one should use them when u need some “extra”-events which r not available in the API – but just because some not bubble?

            There must be the other way?

             

            Please help, dont wona end up with hunderts of custom classes