JSFL: library.itemExists Bug?

library.itemExists method fails to understand the character (upper/lower case) difference.

As per the documentation, this method returns “true” if the specified item exists in the library & “false” otherwise.

Create a folder named “MovieClips” in the Library & try following code:
fl.getDocumentDOM().library.itemExists(“movieclips”);
Notice that all characters are same. Only difference is the string is in small case.

It returns false! & if you try to create folder using following code, it silently fails.
fl.getDocumentDOM().library.newFolder(“movieclips”);

However if you manually try to create folder using Library Panel, you will get an error message “The name “movieclips” is already taken. Please use a different name.

Here is the JSFL code I am using:
// JSFL Script
var doc;
var folderName = “MovieClips”
// Initialization
function init() {
fl.outputPanel.clear();
doc = fl.getDocumentDOM();
if (doc != null) {
var lib = doc.library;
if(!lib.itemExists(folderName)){
lib.newFolder(folderName);
fl.trace(‘Success. ‘+folderName+’ created.’);
} else {
fl.trace(‘Error. ‘+folderName+’ already exists.’);
}
} else {
fl.trace(‘Error. You must open a FLA file first.’);
}
}
init();
// End Script

Any comments?

Advertisements

About Tushar

Hi, I am Tushar Wadekar from Pune, India. I am an Adobe Certified Flash Developer. My Interests are: Flash, ActionScript, Flex, AIR, PHP, Ruby on Rails. You can reach me at: tusharwadekar[at]gmail[dot]com Thank you! Tushar
This entry was posted in JSFL. Bookmark the permalink.

One Response to JSFL: library.itemExists Bug?

  1. Sadly this bug still seems to exist ten years later.

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