Home > Error, JSFL > Flash JSFL Utility

Flash JSFL Utility

Back to Flash world after long time. Everything is good.

I found this utility useful especially when working with multiple fla;s which needs to exported on every time when launching the game. Everything goes fine, until there is an compile time error while launching. If there’s one, then launching the game with errors seems of no use.

The Flash JSFL utility does by checking for errors., There is no direct way( Not sure if there;s one atleast as per my knowledge, if there’s some hacky way of getting around please post that in comments), so reading the output of the compile panel and saving it to a text file , reading that text file contents and checking if there is any error or warning against that output.

If there’s no error flash would output in certain way like

0 Error(s), 0 Warning(s)

Right here were the steps to get into that

var exportSWFs=new Array();

exportSWFs.push(gameManager);

exportSWFs.push(game);

exportSWFs.push(logo);

Push your sequence of swf’s into an array. The gameManager could be of an array with values formed from source path of the fla and destination where the swf needs to be published.

for (var i = 0; i < exportSWFs.length; i++)

{

var documentObj= fl.openDocument(exportSWFs[i][0]);

documentObj.exportSWF(exportSWFs[i][1],true);

// creating a file name based on document

var docErrorURI= logDirURI + documentObj.name + “.errors”

// saving the contents of the errors

fl.compilerErrors.save(docErrorURI);

// reading the contents of the error from file

var contents = FLfile.read(docErrorURI);

// If there is no errors and warnings , it prints out like 0 Error(s), 0 Warning(s)

// getting errorCount from the above output; Not sure if regular expression works here

var errorCount = (contents.split(“Error(s)”)[0]).split(”)[(contents.split(“Error(s)”)[0]).length-2];

FLfile.remove(docErrorURI);

if (errorCount != “0”) {

// Dont want to continue with rest of export — I dont want to compile the fla with errors

success = false; break;

} }

if (success) {

// Do launch game here

}else{

alert(“There were errors in ” + documentObj.name);

}

Advertisements
Categories: Error, JSFL
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: