Copy link to clipboard
Copied
Hello,
Is there a way to trigger an event in JSFL and capture it in a CEP extension?
For example:
csInterface.addEventListener("eventTriggeredFromJSFL", () => { "doSomethingHere"; });
csInterface.evalScript('fl.addEventListener("prePublish", function () { "dispatchEventHere"; });');
Actually, is there any way to trigger an action in a CEP extension through JSFL?
Kind Regards,
Ognyan
Turns out that there is a set of CEP events specifically for Animate. These events would be captured by the CEP VM listener when triggered by actions on Animate docs, and reflect most of JSFL event types of its VM listener (but there is no correspondence for prePublish and postPublish I'm afraid):
com.adobe.events.flash.documentChanged
com.adobe.events.flash.timelineChanged
com.adobe.events.flash.documentSaved
com.adobe.events.flash.documentOpened
com.adobe.events.flash.documentClosed
com.adobe.events
...Copy link to clipboard
Copied
If I understand your problem correctly, you should know that evalScript has the capabilities of retrieving the result of the script it evaluates in the form of a string, and it can be passed in a callback function as parameter. So rather than register a listener in the JSFL script and dispatching from there, you could just dispatching it from the CEP panel using the result of evalScript. This is what I would do:
cs.addEventListener("eventTriggeredFromJSFL", () => { "doSomethingHere"; });
cs.evalScript('yourJSFLfunction()', function(resultFromJSFL) {cs.dispatchEvent(resultFromJSFL);
});
Copy link to clipboard
Copied
Hey b_oggre,
I would like to trigger an event from JSFL and capture it in CEP.
I would like to do this when starting Animate with a JSFL script which runs directly in JSFL, but I would like to call my extension to do something. Also, since the "system" events (prePublish, postPublish, selectionChanged) are really broken when you capture them with csInterface.addEventListener, but work rather fine with fl.addEventListener, I would like to call my extension on an event capture in fl.
Regards
Copy link to clipboard
Copied
So you would like to dispatch an event from JSFL without any previous action was performed on the CEP panel and then you want that event to be captured by the CEP panel, am I correct? If that so, as far as I know, the system events of the Flash API won't ever reach the CEP panel because JSFL and CEP lie on different Virtual Machines. The only ways of communication between the two VM are using cs.evalScript, CSEvents and VulcanMessages, but the last twos are intended to be used always inside the CEP VM (respectively for panel's intra-communication and for panles' inter-communication). So I would say that the "correct" way of doing what are you trying to accomplish, in my opinion, is to use evalScript, since it is intended to be the method for communicating between the different Adobe VMs, but that would mean that you'll have to run your JSFL script through some sort of button in your CEP panel. If you don't want to do that, using CSEvents or VulcanMessages inside JSFL might work, but is not for sure. So your code would be
- csInterface.addEventListener("eventTriggeredFromJSFL", () => { "doSomethingHere"; });
- csInterface.evalScript('fl.addEventListener("prePublish", function () { "dispatchEventHere"; });');
where "dispatchEventHere" would become
var event = new CSEvent("eventTriggeredFromJSFL", "APPLICATION"); //APPLICATION is the scope, can be also GLOBAL
event.data = "eventuallyDataToBeDispatched";
csInterface.dispatchEvent(event);
or
var msg = new VulcanMessage (VulcanMessage.TYPE_PREFIX + "eventTriggeredFromJSFL" );
msg.setPayload("eventuallyDataToBeDispatched");
VulcanInterface.dispatchMessage(msg);
in the last case you'll have to register a listener for the VulcanInterface (don't create a new Vulcan, it is a singleton):
VulcanInterface.addMessageListener(VulcanMessage.TYPE_PREFIX + "eventTriggeredFromJSFL", function(message) {"doSomethingHere"; });
As I said, I'm not sure this two solutions can work properly, I'll suggest to use evalScript in your case, but you can give a try anyway
Copy link to clipboard
Copied
Turns out that there is a set of CEP events specifically for Animate. These events would be captured by the CEP VM listener when triggered by actions on Animate docs, and reflect most of JSFL event types of its VM listener (but there is no correspondence for prePublish and postPublish I'm afraid):
com.adobe.events.flash.documentChanged
com.adobe.events.flash.timelineChanged
com.adobe.events.flash.documentSaved
com.adobe.events.flash.documentOpened
com.adobe.events.flash.documentClosed
com.adobe.events.flash.documentNew
com.adobe.events.flash.layerChanged
com.adobe.events.flash.frameChanged
com.adobe.events.flash.selectionChanged
com.adobe.events.flash.mouseMove