Creating Flash Extensions – Responding to a Dialog Choice

Justin | jsfl,Tutorials | Monday, January 9th, 2012

In a previous tutorial, I showed the basics of creating dialogs. In this post, I’ll elaborate on how to respond to a dialog, specifically how to cease execution when the user has selected cancel.

Here’s the code sample that was included in the aforementioned tutorial:

if (result == null) {
//do nothing
} else {
//use the value of result to proceed with the script
}

This example reflects code for custom XMLUI panel, but this technique can also be used for alerts, prompts, and confirmations.

There are 2 easy ways to halt the script if the user has selected cancel and the result is null:

  1. Call a function only if the result is not null.
  2. If the conditional statement above occurs inside a function block, call return to exit the function.

Here’s a code sample for method 1:

var dom = fl.getDocumentDOM();
var xpanel = dom.xmlPanel(absoluteFileLocation);
if (result == null) {
//do nothing
} else {
run();
}

You’d then define a function that execute all of the requisite code:
function run(){
//all the action takes place here
}

If the result is null, the function is never triggered.

Here’s a sample for method 2:

run();
function run(){
var dom = fl.getDocumentDOM();
var xpanel = dom.xmlPanel(absoluteFileLocation);
if (result == null) return;
//continue executing otherwise
}

Essentially, the entire process is wrapped in a function, so it’s easy to jump right out when needed.

Either method will do, sometimes one method suits a particular script.

Creating Flash Extensions — Pt. 7: Distributing to Others

Justin | Animate/Flash,jsfl,Tutorials | Wednesday, March 23rd, 2011

One of the absolute coolest things about Flash extensions is that you can easily share them with others. This tutorial will show you how to create package that can be emailed or posted to a website. That package can then be downloaded by others and installed using Extension Manager.

(more…)

Creating Flash Extensions — Pt. 6: Custom Tools

Justin | Animate/Flash,jsfl,Tutorials | Wednesday, March 16th, 2011

Flash offers the ability to create your own tools and store them in the Flash Toolbar. Tools are probably the most underutilized type of Flash extension. This tutorial will walk through the basics of creating a  tool.
(more…)

Creating Flash Extensions — Pt. 5: SWF Panels

Justin | Animate/Flash,jsfl,Tutorials | Thursday, March 10th, 2011

If you’ve been following this tutorial series thus far, this might be the tutorial you’ve been waiting for. The ability to load a SWF into the Flash Professional interface is definitely one of the coolest aspects of Flash extensibility. There are 2 distinct advantages to building a Flash panel:

  1. Endless visual possibilities
  2. The power of ActionScript

The 1st advantage should be fairly obvious to anyone familiar with Flash’s design and animation capabilities. The 2nd advantage may be slightly less obvious, since ActionScript and JSFL can appear so similar, but ActionScript (3, specifically) has a whole host of capabilities that JSFL does not (network connectivity, timed events, and the ability to interface with nearly any file type using ByteArray, to name a few). The topic of exploiting ActionScript capabilities in a panel actually deserves its own blog post, but for now it’s sufficient to say that SWF panels make cool stuff possible.

This tutorial will serve as a primer, getting you started on the basics of how to load your panel into the Flash interface and how to communicate with JSFL through your SWF.

(more…)

Creating Flash Extensions — Pt. 4: User Interaction

Justin | Animate/Flash,jsfl,Tutorials | Thursday, March 3rd, 2011

The ability to include user interaction into a JSFL script can provide a significant level of flexibility and feedback. Flexibility and feedback are especially useful when you plan to distribute your extension to others. Flexibility allows the script to run differently depending on current conditions. Is there a document open? Are items selected in the Library? Etc. If so, you can ask the user how to proceed. Feedback lets the user know that the script has run properly (or not), so that he/she can proceed with confidence. This tutorial will cover the primary types of user interaction available in JSFL.

(more…)

Page 3 of 512345