On 2010/09/27, in signal, webdev, by a b

Well, the link spam seems to have died down, and I’m getting lonely, so I think I’ll post.

I’ve been working on some code that has made it difficult to use the normal FlashBuilder based process of running in debug and using the step through debugger. This has me spending a lot of time reading through the flashlog.txt file that the debug player output. I also spend a lot of time seeing the dirty secret trace output that every single SWF on the net seems to belch into the log. On a whim, I wrote a script to switch the logging on or off. If you do much work with scripting or sed, this is pretty basic.

sed -i '' 's/=./='"$1"'/g' /Library/Application\ Support/Macromedia/mm.cfg

Put that in a file (such as ~/bin/setFlashLog), make sure you have execute permission, then just type ‘setFlashLog 1’ or ‘setFlashLog 0’, depending on how you want your logging (on or off).

Not being happy with that, I wrote an even more elaborate script to toggle the setting to the opposite of whatever it’s set at now:

read -r FIRSTLINE < /Library/Application\ Support/Macromedia/mm.cfg len=${#FIRSTLINE} idx=$(($len - 1)) value=${FIRSTLINE:idx} if [ "$value" == "1" ]; then sed -i '' 's/=1/=0/g' /Library/Application\ Support/Macromedia/mm.cfg echo "flash logging: off" else sed -i '' 's/=0/=1/g' /Library/Application\ Support/Macromedia/mm.cfg echo "flash logging: on" fi

As with all things *nix, there's probably about 12 other ways to do this. However, since sed was the current favorite hammer, that's what I used to pound the nail. Note that you need the debug player for anything to show up on the log. Also note that the player checks this setting at the time a SWF is loaded, and outputs accordingly. Once the SWF is running, a change in the setting will have no effect.

Last thing; if you're writing a streaming music or video player, don't put trace statements in your progress event handlers. It's really annoying. I'm looking at YOU, soma fm ...

progressHandler for http://streamer-ntc-aa02.somafm.com:80/stream/1018
/;stream.mp3: bytes loaded=404742 bytesTotal=0



Comments are closed.