Copy link to clipboard
Copied
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
Hi,
Yes there is such a possibility. You can register a javascript function to be executed when certain system event occurs:
fl.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 pa
...OK, when you create your list in the panel, you know which document is current - you can store it's name or something unique to create list-document connection.
The "documentChanged" event fires when a document is created, selected, and closed.
So, the swf panel can be informed when the "focus" is changed and can compare the currently focused document ID with the stored one.
// JSFL
documentChangedHandler = function (){
// pass the document name or ID as a parameter
mySWFpanel.call( "ASdocu
...
Copy link to clipboard
Copied
Hi,
Yes there is such a possibility. You can register a javascript function to be executed when certain system event occurs:
fl.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" );
}
Copy link to clipboard
Copied
thank you very much for your answer
I've also found some info about it in
https://help.adobe.com/archive/en_US/flash/cs5/flash_cs5_extending.pdf
on page 244
Copy link to clipboard
Copied
hello
need advice on how to identify my current open document and avoid cleaning of my list in SWF panel when I close other open not selected document in Animate.
JSFL code:
var docCloseID = fl.addEventListener( "documentClosed", onDocumentClosedHandler );
function onDocumentClosedHandler(){
var panelClose = fl.getSwfPanel("mySWFpanel", true );
panelClose.call( "closeDoc" );}
AS code:
ExternalInterface.addCallback('closeDoc', this.clearListMethod );
function clearListMethod() : void {
list.dataProvider.removeAll();
}
Copy link to clipboard
Copied
OK, when you create your list in the panel, you know which document is current - you can store it's name or something unique to create list-document connection.
The "documentChanged" event fires when a document is created, selected, and closed.
So, the swf panel can be informed when the "focus" is changed and can compare the currently focused document ID with the stored one.
// JSFL
documentChangedHandler = function (){
// pass the document name or ID as a parameter
mySWFpanel.call( "ASdocumentChanged", fl.getDocumentDOM().name );
};
fl.addEventListener("documentChanged", documentChangedHandler );
// AS
var myCurrentDocumentName:String;
function ASdocumentChanged( dname:String ) : void {
if( dname === myCurrentDocumentID ){
// OK
}else{
// disable the panel
}
}