Add PWD to Bash Default

I grew up with DOS, so call me a throwback user, but when I open Bash on my Mac, I’d really like to know where the heck I am. By default, the prompt shows your computer’s name, then the name of the directory you’re in. This works fine if you never have duplicate directory names, but when I’m doing dev work, I often have multiple windows open for staging/prod/dev work, and they all have the same name as they’re supposed to. This script goes into your ~/.profile file and will change bash to show something like

~/Documents/Workspace/
>

Here’s the code you put into your ~/.profile file (create one if you need to):

PS1="\[\033[0;32m\]\w/\n\[\033[0;0m\]>"

Cannot Trace using Debugger on OSX

Oh good lord, all I wanted to do was trace the output of my flash debug player, yet there was nothing in the usual location. Typically I just run

tail -f ~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt

in the Terminal and it spits out everything Flash does. The file didn’t exist on my system, so I couldn’t tail it. The solution turned out to be a missing mm.cfg file.
in ~/Library/Application\ Support/, produce a mm.cfg file with the following content:

TraceOutputFileEnable=1
ErrorReportingEnable=1

This, along with a correct debugger, should produce traces.

fl.browseForFileURL won’t work across hard drives

In JSFL, when you use fl.browseForFileURL it returns a URI pointing to the file or folder you’ve chosen. On OX, however, the reference is wrong when you choose a file on a hard drive other than your primary.

Example: I have a hard drive on my mac named HD2. If I browse to a file on there, the URI returned will be

file:///HD2/myFile.txt

If you then immediately try a

FLfile.exists('file:///HD2/myFile.txt')

it returns false. This is due to OSX’s referencing system. the correct location is

file:///Volumes/HD2/myFile.txt

so all we have to do is add the word “Volumes/” to the string and the reference will be correct.

public static function browseForFileURI( title:String = "", type:String = "open" ):String
{
   var ar:Array = MMExecute( "fl.browseForFileURL('" + type + "','" + title + "');" ).split("/");
   ar[2] = "/Volumes";
   return ar.join("/");
}

JSFL 2: Making a Panel

Making a panel in Flash is rather easy, once you find the little bit of information you need. Panels in Flash are just swfs that happen to be in a specific directory.

Windows® 2000 or Windows® XP:
boot drive\Documents and Settings\user\Local Settings\Application Data\Adobe\Flash CS3\language\Configuration\WindowSWF

Mac OS® X:
Macintosh HD/Users/userName/Library/Application Support/Adobe/Flash CS3/language/Configuration/WindowSWF

drop your swf in there, and it should be available in the Windows>Other Panels menu.

Building AS3 Using ANT Scripts

I spent a good chunk of time finding the simplest ANT build script I could and using it to compile my simple AS3 project. This is a simple as it gets:

<project name="build" default="compile">
	<property file="${ant.home}/path.properties"/>
	<taskdef resource="flexTasks.tasks" />
	<target name="compile">
		<mxmlc file="src/AntTest.as" output="bin-debug/AntTest.swf"/>
	</target>
</project>

The project name attribute is up to you.
The default is the target to be run if you just type “ant”
The first property sets basic ANT properties
The taskdef includes Flex-specific information
The target name allows you to reference this action elsewhere in the build file
The mxmlc file is the source for the compiler
The mxmlc output is the output for the compiler
Just replace the as file and swf file with your specific filenames, open up the terminal, browse to the project dir, and type ant
it should produce a swf for you.