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

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

Community Beginner ,
Apr 23, 2020 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

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

Views

1.2K

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 2 Correct answers

Engaged , Apr 23, 2020 Apr 23, 2020

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

...

Votes

Translate

Translate
Engaged , May 08, 2020 May 08, 2020

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

Votes

Translate

Translate
Engaged ,
Apr 23, 2020 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

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
Community Beginner ,
Apr 24, 2020 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

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
Community Beginner ,
Apr 27, 2020 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();
}

 

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
Engaged ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

LATEST

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

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