adding event listener of the closing and changing the FLA document for the SWF extension panel. using ActionScript, JSFL

84 views Asked by At

I have an extension SWF panel and a list of movie clips of the currently open document on it. I want to clear my list when the user closes the current document. Also, I want to add some alert "You have to select the previous document you were work on" - when the user selects other open .fla document and tries to press some button on the SWF panel to edit some MC from the list. So I want to know if has Adobe Animate the ability to listen to closing and changing of documents? thank you for advance for any hints

1

There are 1 answers

0
Andrii On

an answer from adobe community support:

Yes, there is such a possibility. You can register a javascript function to be executed when certain system event occurs:

enter code herefl.addEventListener( eventType, callbackFunction );

The possible system events are: "documentNew", "documentOpened", "documentClosed", "mouseMove", "documentChanged", "layerChanged", "timelineChanged", "frameChanged", “”, "prePublish", "postPublish", "selectionChanged", and "dpiChanged".

Also, in Flash CS4 and above, you have the possibility to refer a particular swf panel. In combination with ExternalInterface class and MMExecute method in AS, you can build a two-way communication between the two environments.

Example:

// JSFL

var docChangedID = fl.addEventListener( "documentChanged", onDocumentChangedHandler );

function onDocumentChangedHandler(){

var panel = fl.getSwfPanel( "<my panel swf file name >", false ); panel.call( "AScustomEventName" );
}

// AS

import adobe.utils.MMExecute; import flash.external.ExternalInterface;

ExternalInterface.addCallback( "AScustomEventName", this.myASMethod );

function myASMethod() : void { // your stuff here
MMExecute( "some jsfl code or path to a jsfl script" );
}