Skip to content

Help, the demonstration code you provided cannot be used correctly #10

@vx19326303120

Description

@vx19326303120

I'm in trouble. In the example, there is an issue with the code provided below. When I copied the following code and used it, I was unable to achieve the described function. I don't know where the problem is. I am a beginner and this is my first time developing because there is currently no one in the world that I want. Last time, I had to study and test it repeatedly for a week before finally getting it done, but it was not saved. I now need to learn and research how to communicate (I have found that communication here is more complex than I imagined, such as communication with HTML). The complexity of communication exceeds my initial imagination. It not only includes bidirectional communication, but also involves, for example, using JSFL code directly in the motion panel of AS3 through certain functions such as MMExecut() and fl. runScript(); 2. Conversely, use AS3 code in JSFL; 3. Pass the entire text code/function/variable parameters in AS3 to JSFL; 4, and vice versa. These things are prone to confusion and confusion. The just inputted over 200 words left the webpage blank, which made me a bit frustrated, to the point where I had to reorganize the language and had to make a long story short.

My purpose in researching and learning this example is to understand the modularity of custom functions and how variables can be passed between AS3 and JSFL. What I want to achieve is how to pass the integers entered by users in the dynamic text of the SWF panel in AS3 of the custom SWF panel to the code in the JSFL file to achieve the following functions. But I found that there were issues with the AS and JSFL code in the example provided here when I copied and imitated it according to the teaching content. I am certain that I did not misplace the file because I am already familiar with the environment in extension development and have implemented some other functions in the extension plugins I have developed. However, besides using MMExecut() and fl. runScript() to directly execute JSFL commands in AS3, I am not very familiar with other communication methods. Actually, I am an animator, and because the plugin for the feature I want cannot be found around the world, I have tried to develop my own AN plug extension plugin.

The following is the example code and connection. I don't know where the problem is with me. Begging the big shots to help me with this cute new:

Portal https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/swfPanel_object/swfPanel.md

Here is a specific example: I suspect there is something wrong with it, or at least it is not suitable for the latest development environment of AS3:

swfPanel.call()
Availability
Flash CS4 Professional.

Usage
swfPanel.call(request)

Parameters
request Parameters to pass to the function (see "Description" and "Example" below).

Returns
Either null or a string that is returned by the function call. The function result could be an empty string.

Description
Method; works in conjunction with the ActionScript ExternalInterface.addCallback() and MMExecute() methods to communicate with the SWF panel from the authoring environment.

Example
The following example illustrates how to use ActionScript and JavaScript code to create a Window SWF panel and communicate with it from the authoring environment.

Create an ActionScript 3.0 FLA file, set its color to a medium gray, and set its size to 400 pixels wide and 250 pixels high.

Place a dynamic text box in the center of the Stage, set its Instance name to myTextField, and type the word "Status" in the text box.

Set other text box properties similar to the following:

Center aligned

355 pixels wide and 46 pixels high

Times New Roman font, 28 points, red

Add the following ActionScript code:

// Here's the callback function to be called from JSAPI
function callMeFromJavascript(arg:String):void
{
try {
var name:String = String(arg);
myTextField.text = name;
} catch (e:Error) {
}
}

// Expose the callback function as "callMySWF"
ExternalInterface.addCallback("callMySWF", callMeFromJavascript);

// run the JSAPI to wire up the callback
MMExecute("fl.runScript( fl.configURI + "WindowSWF/fileOp.jsfl" );");

MMExecute("fl.trace("AS3 File Status Panel Initialized");");
Save the file as fileStatus.fla, and publish the SWF file with the default Publish settings.

Close Flash.

Copy the fileStatus.swf file to the WindowSWF folder, which is a subfolder of the Configuration folder (see "Saving JSFL files"). For example, on Windows XP, the folder is in \boot drive\Documents and Settings\user\Local Settings\Application Data\Adobe\Flash CS4\language\Configuration\WindowSWF.

Start Flash.

Create a JSFL file with the following code:

function callMyPanel(panelName, arg)
{
if(fl.swfPanels.length > 0){
for(x = 0; x < fl.swfPanels.length; x++){
// look for a SWF panel of the specified name, then call the specified AS3
function
// in this example, the panel is named "test" and the AS3 callback is "callMySWF"
if(fl.swfPanels[x].name == panelName) // name busted?
{
fl.swfPanels[x].call("callMySWF",arg);
break;
}
}
}
else
fl.trace("no panels");
}

// define the various handlers for events
documentClosedHandler = function () { callMyPanel("fileStatus", "Document Closed");};
fl.addEventListener("documentClosed", documentClosedHandler );

var dater = "New Document";
documentNewHandler = function () { callMyPanel("fileStatus", dater );};
fl.addEventListener("documentNew", documentNewHandler );

documentOpenedHandler = function () { callMyPanel("fileStatus", "Document Opened");};
fl.addEventListener("documentOpened", documentOpenedHandler );
Save the JSFL file in the same directory as the SWF file, with the name fileOp.jsfl.

Choose Window > Other panels > fileStatus.

Now, as you create, open, and close FLA files, the fileStatus panel displays a message indicating the action you have taken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions