/** Generate embed tags along with property definitions for images in a specified directory. Once the directory is set and the jsfl is run, the embeds will be in the output panel. You can then copy and paste them into your class file. @author Scott Enders */ fl.outputPanel.clear(); // Clear the output panel ///////////////////////////////////////////////////////// // The 3 variables below are the ones you need to edit ///////////////////////////////////////////////////////// var projectDirectory = "/projects/test"; // Directory the project is located var sourceFolder = "/src/main/flex"; // Path of the source folder for the project, relative to the projectDirectory var assetDirectory = "/assets/images/background"; // Path to the assets folder, relative to the sourceFolder var directoryPrefix = "file:///"; // This is required.....don't mess with this var drive = "C|"; // The drive which the project is located.....this is usually the C: drive var directory = directoryPrefix + drive + projectDirectory + sourceFolder + assetDirectory; // Full path to the directory var files = FLfile.listFolder(directory, "files"); // Second parameter specifies to only mess with files in the directory var embedPrefix = "\t\t[Embed(\"" + assetDirectory + "/"; var embedSuffix = "\")]"; // Loop through all files in the asset directory for(var i = 0; i < files.length; i++) { var fileName = files[i]; var lastPeriodIndex = fileName.lastIndexOf("."); var fileNameNoExt = fileName.substr(0, lastPeriodIndex); fl.trace(embedPrefix + fileName + embedSuffix + "private var " + capitalize(fileNameNoExt) + " : Class;"); } /** Capitalize the first letter of the specified file name */ function capitalize(pFileName) { var firstLetter = pFileName.charAt(0); var restOfName = pFileName.slice(1); return firstLetter.toUpperCase() + restOfName; }