Creates a CustomEvent instance with the given arguments.