not "test", so that's one thing to be aware of. You'll need to add
the listener to the Login object, which you can do by giving the
Login component an id (<Login id="loginComponentId" ...>) and then
calling something similar to:
loginComponentId.addEventListener("login", onLoginEvent).
Doug
--- In flexcoders@yahoogroups.com, Andrea Varga <[EMAIL PROTECTED]> wrote:
>
> Well, this worked, but in the Cairngorm framework this was correct
and
> the problem is somewhere else.
> Below is my new little test.
> This time the button that does the dispatchEvent is not in the
> application, but inside another component
>
> The Main.mxml code is almost the same as before, just the Login
> component is new.
> The button with Login1 has the same code as the Login2 button
inside the
> Login component (both dispatch a "test" event).
> But the Application catches just the Login1 event.
> What am I mmissing this time?
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
> layout="absolute" applicationComplete="onComplete()">
> <mx:Script>
> <![CDATA[
>
> [Bindable]
> public var status:String = "";
>
> public function onComplete():void {
> status += "Add Event Listener...\n";
>
> Application.application.addEventListener("test",onTestEvent);
> }
>
> public function onTestEvent(event:Event):void {
> Application.application.status += "Test Event
occured...\n";
> }
>
> public function dispatchTextEvent():void {
> var event:Event = new Event("test");
> dispatchEvent( event );
> status += "Event Dispatched...\n";
> }
> ]]>
> </mx:Script>
>
> <mx:Button x="66" y="56" label="Login1"
click="dispatchTextEvent()" />
> <mx:TextArea x="66" y="123" width="393" height="243"
text="{status}"/>
> <Login x="333" y="56" />
> </mx:Application>
>
> The Login.mxml code:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
> <mx:Script>
> <![CDATA[
> public function loginUser():void
> {
> var event:Event = new Event("login");
> dispatchEvent( event );
> Application.application.status += "Dispatch login
> event...\n";
> }
>
> ]]>
> </mx:Script>
> <mx:ControlBar>
> <mx:Button label="Login2" click="loginUser()" />
> </mx:ControlBar>
> </mx:Canvas>
>
>
> [EMAIL PROTECTED] wrote:
>
> >Try changing
> >
> >
> >public function onTestEvent()
> >to
> >public function onTestEvent(event:Event)
> >
> >
> > You should add event:Event in your listener.
> >
> >
> >
> >
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.