Because the events are dispatched in the MainApp. Your BasePanel dont
receive the event.

--------------------
Application
--------------------
  +  MainApp
--------------------
     + BasePanel
--------------------

The event is dispatched on the MainApp layer, so, even using bubbles you
wont get the event, cause the bubbles goes up.

You could try to add the listener on the Application layer, and use
bubbles, or, use the observer pattern, create a singleton class to
dispatch the event, and add the listener on it.
 

-----Mensagem original-----
De: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] Em
nome de lorenzo.boaro
Enviada em: segunda-feira, 15 de dezembro de 2008 10:09
Para: flexcoders@yahoogroups.com
Assunto: [flexcoders] Custom event--please help me

Hi

i've a problem..anibody can help me?

i created this class:

public class CompleteEvent extends Event
        {
                private var array:ArrayCollection

                public function CompleteEvent(type:String,
array:ArrayCollection)
                {
                        super(type);
                        this.array = array;
                }

                public override function clone():Event {
                return new CompleteEvent(type, array);
        }
}

the main class create the array through a socket connection within the
socket listeners for Socket.DATA...in the method listeners dispatch the
event...

[Event(name="newEvent", type="CompleteEvent")]

public class MainApp{
....
socket.addEventListeners(ProgressEvent.SOCKET_DATA, socketData); ...
private function socketData(event:Event):void {

        ...some code to create array from server data...
        //dispatch event
        var dipsatcher:EventDispatcher = new EventDispatcher();
        var ev:CompleteEvent = new CompleteEvent("newEvent", array);

        dispatcher.dispatchEvent(ev);
  }
}

and this other class listens for the event

public class BasePanel extends Panel
        {

                private function dataEventHandler():void {
                        trace("Array retrieved");
                }

                public function BasePanel()
                {
                        super();
                        this.addEventListener("newEvent",
dataEventHandler);
                }
}

but not working the BasePanel class doesn't listen for the event..

thanks a lot 

Regards
Lorenzo


------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location:
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-
1e62079f6847
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
Links



Reply via email to