Events / signals

Hi,
I’m aware of events and how to handle them. but I can’t find how to make my own event.
If I want one class to inform other of something that just happends… is there any way to make an event or send a signal?

You can.

First make a class representing your event.

class MyEvent extends openfl.events.Event
{
}

Then in your class launching the events extend openfl.events.EventDispatcher and use the function dispatchEvent.

class Aclass extends openfl.events.EventDispatcher {
  function myFunction () {
    dispatchEvent(new MyEvent());
  }
}

https://github.com/openfl/openfl-samples/blob/master/features/events/CreatingCustomEvents/Source/Main.hx

thx,
This is only openfl solution, I have some core classes that I want to use in also in server (without openfl) is it possible?

Since you were asking about signals also, I want to say that ever since I’ve started using signals instead of events, this aspect of programming became so much more efficient (also in terms of runtime efficiency).
This Library also has the ability to interact with old eventDispatcher methods.

######(Sorry for the broken english)