• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a way to trigger an event from Animate's JSFL on a CEP extension?

Explorer ,
Jul 24, 2019 Jul 24, 2019

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

Views

687

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Aug 05, 2019 Aug 05, 2019

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

...

Votes

Translate

Translate
Explorer ,
Aug 01, 2019 Aug 01, 2019

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

});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2019 Aug 02, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2019 Aug 02, 2019

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

  1. csInterface.addEventListener("eventTriggeredFromJSFL", () => { "doSomethingHere"; }); 
  2. 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines