Archive for Batch Scripts

JSFL Get Path of Current Script

Seen alot of confusion with this while searching the web. What I want to do is get the folder path of the script that is currently running. The below code is in URI format and includes the trailing slash. I love automation with scripts so I get to use these features alot:

var scriptURI=fl.scriptURI;

To get the same path in format of your platform:

var scriptPath=fl.scriptURI;

Installing to iOS device directly via AIR 3.4

Flash hasn’t died yet, and this great new feature is definitely an improvement. You can now deploy directly to device without a Mac and now without using iTunes. You still need iTunes on the computer. Here are some instructions on how to do it. First install AIR 3.4 on your Windows machine:

Just get the ZIP version and make a folder on your C drive “c:\air3.4”. I’ve made a habit of putting command line programs right on my C drive to save headaches. I notice one problem, your builds have to use your “Ad Hoc Provisioning Profile” AND “Deployment – Ad Hoc” or you’ll get a “Installation Error: PackageExtractionFailed” error. I also got “Installation Error: PackageInspectionFailed” but I recompiled to fixed it. Hopefully they’ll fix this soon because Google is not turning up anything about those errors. Eventually it would be great for remote debugging builds, but for now if I notice anything funny, I’ll just build a debug version and install using my Mac as usual. Here are my iOS publish settings:

All you have to do is publish your app and in the folder of the resulting IPA you can create a BAT file to uninstall and install the app in one shot. Now I don’t have to run to my iMac just to install. Here is my BAT file, please let me know if it needs improvement. This assumes you only have one iOS device attached (via USB) to your Windows machine:

@echo off
echo Uninstalling ...
call c:\air3.4\bin\adt -uninstallApp -platform ios -appid com.mysite.MyGame
echo Sleeping ...
ping -n 5 >nul
echo Installing ...
call c:\air3.4\bin\adt -installApp -platform ios -package MyGame.ipa

I put a sleep in there because sometimes when I uninstall the device blanks out for a few seconds, but sometimes it doesn’t and works fine. Anyway, I’m using this script to dramatically increase my device testing time. Good work Adobe!

CS5.5 JSFL dynamic publish settings

It seems like I’m only one of the very few people in the world who actually use JSFL for their projects, because Google just can’t find anything on it.  For those of you who are looking to use JSFL to dynamically change their publish settings so they can for example make a version with “Omit Trace Actions” and one without.  Or better yet, different config constant settings here is a good example:

var doc=fl.getDocumentDOM();
var profile;
var flashFileName;
//Delete a prev attempted temp profile
if (doc.publishProfiles.indexOf('@temp') != -1) {
  doc.currentPublishProfile = '@temp';
//Make a copy of the 1st profile and tweak
profile=new XML(doc.exportPublishProfileString());
profile.PublishFlashProperties.DebuggingPermitted=1; //Need debugging
//Publish it now and delete the temp profile

Pay special attention to “AS3ConfigConst” because you can’t just set it directly. You must re-enclose it in XML. It took me almost a day to figure that out, cause no one else in the inter-web-nets has gone this far. So your welcome the handful of you adventurous JSFL programmers. Please comment so I know you exist 🙂

CS5.5 JSFL convert selected to bitmaps

For all you CS5.5 mobile guys out there. When I try to “Convert to Bitmap” on multiple objects it will lump them all together to one bitmap, usually not what you want. When I heard of this feature I thought it would be great if it could convert an entire timeline to one bitmap each but that’s not how it works. With the below JSFL you can select multiple objects, even using the multiframe option, and convert each one individually to bitmaps. This will convert all the effects (glows, dropshadows) to bitmap which can allow you to keep your effects in GPU mode. I recommend to stay with AIR2.6 for GPU mode for now. Nothing is faster than GPU mode, but if you have dynamic text or effects you can’t use it.

//Convert all selected objects to bitmap individually
//By T.Suriyathep 6/28/2011
if(fl.getDocumentDOM().selection.length==0) { //Nothing selected
  alert("You must select elements on stage!");
else { //Select and convert one at a time
  var sel=new Array();
  for(i=0;i<fl.getDocumentDOM().selection.length;i++) {
  for(i=0;i<sel.length;i++) {
  alert("All selected converted to bitmap!");

Recursively remove all SVN folders

If you work with SVN programs like Tortoise SVN then you might like this script. If you like automating stuff then you’ll also like this. Save this as a Windows BAT file, and copy it to the root folder that you want to wipe out all “.svn” folders. Run it and it will magically clean everything recursively.

@echo off
for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (rd /s /q "%%i")