JSFL refers to Flash JavaScript, a JavaScript script file that is an important tool for extending the Flash IDE. As a AS3 programmer, learning and mastering the use of JSFL is very important after using JSFL you will be surprised to find that, wow, originally can be so efficient to do flash development. During the AS3 development process, editing the FLA and using it is an important process when a FLA sets the final version. Mature development often backs up the resources in the finalized version to SVN. This completes the backup and makes it easy to look in the folder directly when you want to use a single picture. Because a FLA often involves a lot of pictures, if rely on a picture of the human to export, and then categorize, save. It is time-consuming, laborious, and prone to omission. Then we want to be able to write a script ourselves, let the code help us implement this process.
Here is a complete example of a JSFL:
var doc = Fl.getdocumentdom ();
var name = Doc.name;
The set output path is Flaout
var path = "file:///D:/flaout/";
Gets the FLA filename and removes the. fla extension
var dir = name.substring (0, name.length-4)
var items = doc.library.items;
Path = path + dir;
Create a directory
Flfile.createfolder (path) with the same name as the FLA in the output path;
for (i = 0; i < items.length i++)
{
if (Items[i].itemtype = "Bitmap")
{
fl.trace ("Output file =>" + PA th + "/" +items[i].name);
Items[i].allowsmoothing = true;
Items[i].compressiontype = "lossless";
Gets the current component directory
var subpath = path + "/" + Items[i].name;
Subpath = subpath.substring (0,subpath.lastindexof ("/"));
Create a directory
Flfile.createfolder (subpath);
Output file
items[i].exporttofile (path + "/" + Items[i].name);
}
Alert ("Output complete, close file, do not save");
The above is a JSFL file code that puts this code in a notepad with the suffix name changed to. JSFL here named EXPORTFILE.JSFL use Adobe Flash CS to open a FLA click commands--> Run Command ... Select EXPORTFILE.JSFL. The FLA is not saved after the output is not saved because we simply export the picture in the FLA and do not need to modify the Fla. You can see all the pictures in this FLA in d:/flaout if you need to, you can modify the saved path yourself.