I’m not entirely sure what you’re trying to accomplish here.  But in your callListener function you create the Dispatcher as a local variable which means it doesn’t last long.  Using the tag means it should have stuck around:

 

Something like this:

 

<Dispatcher called=”callHandler(event)” />

 

Matt

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Kaushik Mukherjee
Sent: Thursday, January 12, 2006 7:09 AM
To: [email protected]
Subject: [flexcoders] EventDIspatcher in Flex 2.0 alpha

 

Hi,

I am facing a problem with dispatchEvent method, where I want to create own class and eventListener, in Flex ALpha 2.  But it is not giving the result.

 

Defautl File

dispatchListenerTest.mxml

CODE

_____________

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">

<mx:HBox width="100%" height="100%">

<mx:Script>

<![CDATA[

import flash.events.*;

private function callListener():Void{

var dispatcher:Dispatcher = new Dispatcher();

dispatcher.addEventListener("called", callHandeler);

}

public function callHandeler(event:AsDispatcher):Void{

tb.text = event.dta;

}

//<Dispatcher/>

]]>

</mx:Script>

<mx:Button label="Button" click="{callListener()}"/>

<mx:Label id="tb" text="Hello"/>

</mx:HBox>

</mx:Application>

__________________________________________

 

 

 

 

Dispatcher.mxml

____________________________________

 

<?xml version="1.0" encoding="utf-8"?>

<mx:TitleWindow xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" creationComplete="{called()}">

<mx:Script>

<![CDATA[

import flash.events.*;

public function called():Void

{

public var dta:String = "Hello";

dispatchEvent(new AsDispatcher(dta));

}

//<mx:Button label="DIspatch Event" click="{called()}"/>

]]>

</mx:Script>

<mx:Metadata>

[Event("called")]

</mx:Metadata>

</mx:TitleWindow>

 

___________________________________

 

AsDispatcher.as

 

_____________________________________

 

// ActionScript file

package{

public class AsDispatcher extends flash.events.Event

{

public var dta:String;

public function AsDispatcher(_dta:String)

{

super("called");

dta = _dta;

}

}

}

 

______________________________________

 

 

If anybody is having give me the solution, sample, it will be great help.

Thanks in advance

Kaushik

Send instant messages to your online friends http://in.messenger.yahoo.com


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