Highlighted

adding event listener of closing and changing the FLA document for SWF extn panel JSFL actionscript

Community Beginner ,
Apr 23, 2020

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.

AndriiB1987_3-1587673628904.png
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

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
	  }
}

 

 

 

TOPICS
ActionScript, Code, Exchange extensions, How to, Missing feature, Other

Views

714

Likes

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

adding event listener of closing and changing the FLA document for SWF extn panel JSFL actionscript

Community Beginner ,
Apr 23, 2020

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.

AndriiB1987_3-1587673628904.png
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

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
	  }
}

 

 

 

TOPICS
ActionScript, Code, Exchange extensions, How to, Missing feature, Other

Views

715

Likes

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
Apr 23, 2020 0
Participant ,
Apr 23, 2020

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

 

 

 

 

 

 

 

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Likes

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
Reply
Loading...
Apr 23, 2020 2
Community Beginner ,
Apr 24, 2020

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

Likes

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
Reply
Loading...
Apr 24, 2020 0
Community Beginner ,
Apr 27, 2020

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

 

Likes

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
Reply
Loading...
Apr 27, 2020 0
Participant ,
May 08, 2020

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
	  }
}

 

 

 

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

Likes

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
Reply
Loading...
May 08, 2020 2