When you work with FDT to create flash products, there are a number of ways to compile your code and view the result. My favorite way is by using the External SWF Viewer, which remembers it’s size and where it sits, and correctly obtains focus when ready for action. However, when you’re dealing with a project that needs a specific browser to run in, the standard “open in browser” feature of FDT (or Flex for that matter), has shortcomings. I don’t like that it opens a new window or tab every time you hit compile, which is especially painful if you’re doing things with performance guzzlers like Papervision. The alternative where you have to refresh the page with your keyboard or mouse is equally painful.
Jankees van Woezik had me thinking of it a while back, when he came up with a little ANT method to focus Firefox, and then a Javascript to reload the page. That however, doesn’t work too well when you’re running an open social platform like Facebook, or its Dutch counterpart Hyves.
With a little more googling I stumbled upon Fresno, a pretty nifty command line tool for executing Javascript in Firefox via MozRepl, a Mozilla add-on. Guess what you get when you combine them with ANT? Instant focus and reloading in Firefox from within your build script!
Download Fresno from their SVN repository (I like having it as an svn:external in the projects that use it) and install the MozRepl add-on. Be sure to actually start it from the Firefox tools menu, or Fresno can’t connect to it. After that, take this ANT target and modify it to have the fresno directory match your project.
<target name="focus Firefox and reload page"> <exec executable="open"> <arg line="-a Firefox" /> </exec> <exec executable="flash/tools/fresno/fresno"> <arg line="-j 'content.location.reload()'" /> </exec> </target>
Et voila! Works like a charm, and saves you quite a lot of valuable keystrokes!
Pingback: FDT workflow enhancement: fast reloading | base42.nl
Pingback: My workflow with ANT and FDT | base42.nl
It works really well, but I have one problem: after reloading in FireFox it still opens a new tab in my default browser (Chrome for that matter).
So does this mean I need FireFox also to be default browser to prevent this?
@adehaas: could it be that you still have “start SWF” checked in the run configuration?
Pingback: FDT and ANT – part 2 | [mck]