Doug Lowder wrote:

>Hmm, the code you posted for Login.mxml dispatches a "login" event,
>not "test", so that's one thing to be aware of. 
>
Yes, this was definitely a problem, but not THE problem.

>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).

>
Yes, this works, but I don't want to do that. My application won't  know
who dispathes the event, just wants to know that it was dispatched.

I created this test just to get a bit confortable with events, and to
try to catch what is the problem in my original project which uses
Cairngorm.
In Cairngorm, in the FrontController's addCommand method, the listener
is registered to Application.application. But it is not working in my
project,  and obviusly the problem is not in Cairngorm.

Thanks
Andi



>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
>Yahoo! Groups Links
>
>
>
>
>

>


--
Andrea Varga
Managing Partner / Project Manager
Certified Macromedia Flash MX 2004 Developer

--
Spin Development Srl

Tel: +44 207 043 1304
Fax: +44 207 681 1376
Skype ID: vargaandrea

Mon-Fri : 8 AM - 5 PM GMT+2
Saturday: 8 AM - 4 PM GMT+2 (Support only)
------------------------------------------



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to