well, you should not dispatch the event right in the constructor, nobody would be able to catch it (it's too fast).
moderations as following:
----------------------------------------
package com.test {
import flash.display.Sprite;
import flash.events.Event;
import com.test.EventManager;
import mx.controls.Alert;
public class TestDispatcherClass extends Sprite {
public function TestDispatcherClass()
{
//dispatch a event every 2 second
setInterval(makeNoise, 2000);
}
private function makeNoise(){
this.dispatchEvent(new Event("action"));
}
}
}
package com.test {
import com.test.EventManager;
import flash.events.EventDispatcher;
import flash.events.Event;
import mx.controls.Alert;
import flash.display.Sprite;
public class TestHandler extends Sprite {
public function TestHandler()
{
//create a TestDispatcherClass instance here and add listener to it
var dispatcher:TestDispatcherClass = new TestDispatcherClass();
dispatcher.addEventListener("action", actionHandler);
}
public function actionHandler(event:Event):void
{
Alert.show("hanlded event:" + event.toString());
}
}
}
.mxml:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns="*" creationComplete="this.initApp();">
<mx:Script>
<![CDATA[
import com.test.TestHandler;
import com.test.TestDispatcherClass;
private var test:TestHandler;
//private var dispatcher:TestDispatcherClass;
private function initApp():void {
this.test = new TestHandler();
//this.dispatcher = new TestDispatcherClass();
}
]]>
</mx:Script>
</mx:Application>
---------------
please note : this is just one way to do it, there are many other possible ways can be used toward different scenerios, but this one should get you started.
Jeremy.
__._,_.___
--
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.

