Enterprise Architect for Actionscript
Good habits – http://imanit.com/blog/?p=43
How To – Create a class model from an AS project – http://fasanya.blogspot.com/2010/04/using-enterprise-architect-to-create.html
How To – Configuring EA, creating a diagram, generating stub code – http://dgrigg.com/blog/2006/09/14/uml-stub-code-and-asdocs/
Alternatives to Enterprise Architect for Actionscript:
UML4AS – http://www.uml4as.com/flower-platform/home-uml4as.html
ArgoUML – http://argouml.tigris.org/tours/
StarUML – http://www.senocular.com/flash/tutorials/starumltoas3/
CrocusUML – http://crocusmodeller.com/
http://crocusmodeller.com/
Automatic Actionscript API documentation – JavaDoc comments, ANT, NaturalDocs
I needed a JavaDoc documentation solution for our ActionScript 3 API. We’ll soon be engaging offshore contractors to build content using our in-house AS3 framework and up-to-the-minute documentation is a must-have.
Our development environment is Eclipse, FDT, ANT, Windows, and the solution needs to be as automatic as possible.
Previously I’d used DoxyGen but after some quick Googling I found a tool – NaturalDocs - with specific ActionScript support.
Generating NaturalDocs as part of an ANT build in Eclipse requires:
- Python to be installed on your computer
- the NaturalDocs installation
- an ANT script (here’s my example)
I do minimal command-line work, and less Python, but the process worked almost immediately for me. If you run into problems check the troubleshooting page on the NaturalDocs site.
<property file=”../../_properties/workspace.properties”/>
<property file=”../../_properties/app.properties”/>
<target name=”naturaldocs”>
<!– naturaldocs generates HTML documentation from AS3 JavaDoc comments –>
<echo>${project.name} Building HTML documentation</echo>
<property name=”perl.path” value=”perl”/>
<property name=”nd.path” value=”C:\NaturalDocs-1.51\NaturalDocs”/>
<property name=”nd.format” value= “FramedHTML” />
<property name=”nd.doc_dir” value= “${src.dir}/documentation” />
<property name=”nd.code_dir” value= “${src.dir}” />
<property name=”library.gaia.dir” value=”C:\_workspace/CLASS_LIBRARY_AS3/as3_lib_catalyst/src/com/gaia” />
<property name=”nd.work_dir” value= “${src.dir}/documentation/project” />
<property name=”exepath” value=”${nd.path}NaturalDocs -i ${src.dir} -o FramedHTML ${nd.doc_dir} -p ${nd.work_dir}”/>
<!– The ‘exepath’ below can be copied and pasted for command-line testing outsied Eclipse –>
<echo>${exepath}</echo>
<mkdir dir=”${nd.doc_dir}”/>
<mkdir dir=”${nd.work_dir}”/>
<echo>Producing NaturalDocs documentation files now (this may take a few minutes)…</echo>
<exec executable=”${perl.path}”>
<arg line=”${nd.path}”/>
<arg line=”-o ${nd.format} ${nd.doc_dir}”/>
<arg line=”-i ${nd.code_dir}”/>
<arg line=”-i ${library.gaia.dir}”/>
<arg line=”-p ${nd.work_dir}”/>
</exec>
<echo>NaturalDocs production complete.</echo>
<delete dir=”${nd.work_dir}”></delete>
<echo>NaturalDocs cleanup complete.</echo>
</target>
</project>
Flash debugging and diagnostic tools
Over the years I’ve tried a lot of different Flash debugging and testing tools. Whether I’m on my development workstation or at a client site I keep a stash of installers for these handy at all times.
Here’s a list of the ones worth keeping – there’s no problem that these tools can’t discover. And (with the exception of Charles) they’re all FREE!
- Charles HTTP proxy – see exactly what’s being requested and returned (great for revealing server errors)
- Firefox – Allows me to run the Flash Switcher and Flash Tracer plugins
- Flash Switcher – easily test in multiple versions of the Flash Player
- Flashtracer – View the log output of the Debug Player, includes pattern matching and text colouring
- A text document with an example of a valid path to flashlog.txt (to make up for having a bad memory!)
- Installers for Debug Flash Player 9 and 10, ActiveX/plugin/standalone
- A copy of my own ‘mm.cfg’ file (to copy onto a client machine if required)
Assuming that I need to visit a client site to test an issue (a rare occurence, but that makes it even more important that I get in, do the business and get out as quickly and reliably as possible!) I can start with a ‘virgin’ machine and have it loaded with my test suite in under 20 minutes.
Additionally, when I’m testing and debugging on my development machine, I always install:
- dnGREP – Easy, fast, multi-line search and replace
- MonsterDebugger – Provides ‘Flash Debug’ style object introspection
- Launchy – Indispensible shortcut tool
- WAMPServer – Reliable testing of local content in a webserver environment
Other useful compilations of Flash and Flex debugging and diagnostic tools are:
the list of helpful Flex or Flash debug tools
*drawlogic’s Helpful Flash Debugging Tools
What about you? Are there any tools you can’t live without?
Better memory management in AS3 with Temple Library
After seeing some memory issues with a large Gaia Flash Framework project I was directed to the Temple Memory Management library.
By extending the Gaia AbstractPage from the Temple ‘CoreMovielip’ class instead of the Flash MovieClip class I gained a bunch of useful cleanup functions that operate pretty much on ‘auto pilot’ and instantly reduced my memory overhead with no additional work.
In addition to memory management there are a bunch of other useful ‘toolkit’ classes. Like the Gaia framework, this is a well-thought-out structure that you can use as much (or as little) as you like. Just the memory management alone makes it worthwhile, the rest is up to you.
RobotLegs with Gaia Flash Framework, getting started
I’ve used Gaia for a couple of years and recently started to integrate RobotLegs into my projects.
My ‘most useful references’ are:
RobotLegs ‘Hello World’ video – John Lindquist
This video is also a brilliant demo for writing code fast with FDT. I’ve watched it over a dozen times and learn something new regularly. When I watch John creating the Hello World example from scratch I see the state of ‘flow’ I want to replicate in my own work. My current favourite keyboard shortcut is ‘CTRL-PageUp and CTRL-PageDown to navigate between open files in the Eclipse IDE.
How to Use RobotLegs on top of Gaia (part deux) – JesterXL
Gaia and RobotLegs Together
Common Problems – RobotLegs – I reached this page with three ‘common problems’ – I wasn’t exporting a SWC from Flash, I’d already added my View class to the stage before I’d mapped the Mediator, and I had a semi-colon after my [Inject], all definite no-no’s.
‘Fluxus’ – Flex and Actionscript Library / Package management repository (think Ruby Gems or Perl CPAN)
Described by one of the project owners as ‘like RubyGems for the Flash platform’, the Fluxus Project currently provides a database of AS3 libraries, and will ‘soon’ feature a command-line interface to the database, and a GUI to manage your local ‘Fluxus’.
Anyone already on GitHub should ‘watch’ this, it’s gonna get seriously useful. And if you’ve got skills you can use to help the community out then head over to http://fluxdb.fluxusproject.org/
Check it out – over 270 AS3 libraries and counting!
Building an AS3 FLA based component with a SWFPanel and a LivePreview
In learning how to make AS3 components I found a large amount of frustration with Adobe’s documentation. Every useful resource I found had a slightly different (yet valid) approach to the finer points of component development. It seems everyone has a different solution depending on their requirements, so be prepared to read a lot before you dive in.
The online resources I used were:
- The exhaustive Jeff Kamerer articles on the Adobe site based on the UIComponent framework
- A non-UIComponent solution from David Barlia’s ‘Studio Barliesque’ blog
- A slightly less complex implementation than mine at RedBjarne’s Blog
- A shorter, simpler article by Chris Sperry
- Useful background info about custom parameter UIs (SWFPanels) and JSFL from Keith Peters
- Adobe documentation for JSFL in Flash CS4
Example files:
My finished files are available here for download. Because this component requires some absolute filepath parameters I recommend:
- Placing the extracted directory at the root level of your ‘C’ drive
- Macintosh users will need to replace the current ‘c|’ characters with the relevant drive name and delimiter characters.
OK, on with development…
My requirements
I needed a component that could be used by (low tech-savvy) design staff to preview external text in the Flash IDE. The text is HTML tagged CDATA within an XML document. The project uses embedded fonts too, so it was critical that what appeared in the IDE was exactly what appeared in the published SWF.
In a nutshell, I needed an AS3 component with a LivePreview (to load and correctly display the embedded fonts), and a SWFPreview (to display the component parameters in a more legible fashion that the standard Flash component parameters panel).

This image shows XMLTextArea Component instances displaying CSS styled HTMLText in the Flash CS4 IDE with an embedded font (the font is NOT an active Windows font, it's embedded in a SWF that's loaded for use by the LivePreview). Note the list items in the bottom instance, they're indented using CSS, not by the addition of 'space' characters into the text.
Step 1: Creating the ‘shell’
Setting up a development workflow is straightforward as long as you remember the 3 elements of the component (runtime, live preview, SWF panel). I made a directory with some empty FLAs first:
- XMLTextAreaComponent.fla (to contain and test the component during development)
- XMLTextAreaComponentLivePreview.fla (to build the LivePreview SWF that you’ll see in the Flash IDE while authoring with component), and
- XMLTextAreaComponentSWFPanel.fla to develop a functional UI instead of using the Component Parameters panel.
Next, create the Document classes for each of these FLAs. Using a consistent naming convention throughout development is critical, it lets me focus on the problems that need solving instead of wondering which class or fla I’m looking at. The Document classes are named as follows:
- com.ui.textarea.component.XMLTextAreaComponent.as
- com.ui.textarea.component.XMLTextAreaComponentLivePreview.as
- com.ui.textarea.component.XMLTextAreaComponentSWFPanel.as
You can download my finished Flash CS4 (Windows) files from here. I’d recommend putting the directory at the root of your ‘C’ drive, that way you couldn’t need to change any of the component instance parameters to see the XMLTextAreaComponentTest.fla functioning correctly.
Step 2: Build the SWFPanel
For me, the SWFPanel is the logical place to start. It focuses attention on the functional requirements of the component. The XMLTextArea needs a relatively large amount of startup configuration (text source, stylesheet, external fonts, author-time and runtime location info) that would be inconvenient to set using the standard Component Parameters panel.

This image is a populated SWFPanel for one of the onstage instances of the component. This is currently quite clumsy looking, but it points each instance to its XML text file, SWF containing the embedded fonts and stylesheet at runtime and author-time.
First I laid out my SWFPanel UI (XMLTextAreaComponentSWFPanel.fla), then named my component instances. I always have ‘Automatically declare stage instances’ turned off in my FLAs, so in the com.ui.textarea.component.XMLTextAreaSWFPanel class you’ll see I’ve declared each component instance as follows:
When we change something in the SWFPanel we need to communicate that change explicitly to the selected onstage instance of the component. Conversely, the SWFPanel also needs to be initialised with the onstage component instance parameters. Here are the JSFL commands to retrieve the onstage instance values:
…and here’s how we populate the SWFpanel (see the init() method of the XMLTextAreaSWFPanel class) when an instance of the component is selected onstage:
Lastly, we need to update the component parameters of the onstage instance whenever we use the SWFPanel to make changes. I do that with event listeners that issue more JSFL commands, like so:
The rest of the XMLTextAreaComponentSWFPanel class just implements these concepts for all the other UI widgets. The important concepts are:
- the SWFPanel uses JSFL to communicate with the onstage instance
- it’s one-way communication, the SWFPanel does all the work of interrogating onstage instances and updating itself
- the component instance can’t dynamically talk to the SWFPanel, other than when it’s selected, and that’s only to expose its component parameters.
To test the JSFL communication we need to connect the SWFPanel up to a component instance, so the next step is to build a basic version of the component, give it some parameters and connect it to the SWFPanel.
Step 3: The Component – parameters
OK, next I create the basic component. Make a MovieClip, then in the Library right-click and select ‘Component Definition’. For this one I enter the Class as ‘com.ui.textarea.component.XMLTextAreaComponent‘ and point the ‘Custom UI’ field to ‘XMLTextAreaComponentSWF.swf‘. During development I prefer to use the ‘Custom UI in external .swf file’ option. It makes updating much quicker if I make changes to the SWFPanel for any reason. In addition to setting the class in the component definition I also needed to set the Linkage ID in the ‘Properties’ panel.
Because I’m still a component newbie (and it’s hard enough to keep track of the basics right now), I’ve chosen to extend the UIComponent class and override the ‘configUI()’ method. I set up my component clip with the same 2 frame structure discussed in the Jeff Kamerer articles on the Adobe site and it worked for me (i.e. compiled without errors) immediately.
Once you’ve linked the component clip in your Library to the component class file you’ll find that any changes you make to the ‘Parameters’ list in the ‘Component Definition’ panel won’t be saved. This is because the component now looks to the Class you nominated for its’ parameters. These need to be defined with getters and setters like so:
I found that unless I included the ‘name’ parameter in the ‘Inspectable’ metadata the component parameter wasn’t available to me from JSFL in the SWF panel. Dunno why, it just worked for me this way. This process was repeated for all component parameters, then I right-clicked the component movieclip in the Library and chose ‘Component Definition’, and clicked ‘OK’ again. We need to do this anytime we make changes to the component class that would affect it’s functionality in the Flash IDE. Since we’ve just added component parameter getters and setters in the component class we need to update it before it can be properly tested.
Now I tested the communication between my SWFPanel UI widgets and the onstage component instances.
Step 4 – The LivePreview
This is probably my favourite part of FLA-based component development because it brings completely customised functionality and appearance to the Flash IDE. From within the IDE the LivePreview loads the fonts, CSS and HTML, and renders the text onscreen exactly as it renders at runtime. Designers can work with visible, correctly styled external HTML text, and all the text remains external to the FLAs (so translation or revision can be completed with no recompiling).
The basic framework of a LivePreview SWF can be seen in my example files:
- The Document Class of the LivePreview.fla should be set to fl.livepreview.LivePreviewParent
- In frame 1 on the timeline, a clip (with a Linkage to the XMLTextAreaComponentLivePreview class) that contains an onstage instance named ‘avatar_mc’. (I also included a TextArea component and some dynamic TextFields, but later converted these to guide layers, they’re still present in my example files).
- The XMLTextAreaLivePreview class extends UIComponent and overrides the setSize() and draw() methods
- All the component parameters need getters and setters in the XMLTextAreaLivePreview class to access their values in the IDE at authoring time.
All the action in my component happens in the draw() method after the fonts, XML and CSS are loaded and parsed.
NB: The onstage LivePreview won’t update dynamically while you’re resizing it. This is also a constraint of the components provided by Adobe, so I didn’t stress too much about finding a solution. If you have one, please leave a note in the comments.
Step 5 – Deployment
All our Flash team members (designers and developers) are also connected to our classes via SubVersion. Currently the component is in ‘beta’, being tested by a couple of key staff, so I haven’t yet prepared an MXP for distribution. When that happens I’ll add my notes here.
Finally
There’s one more ‘dirty little secret’ in this component. When I changed the ‘visibleXMLText’ component parameter in an onstage instance, it wouldn’t automatically refresh the view (even though it could trace out the updated text) so I used JSFL to deselect and reselect the component in question (found the technique here). Unfortunately it breaks the Flash ‘undo’ functionality for any onstage instance of this component. Yes, it sucks, but it’s not a showstopper. Again, if you have an idea that might work, tell me in the comments please.
AIR runtime breaks AS2 flashlog.txt output
Yesterday I installed the AIR runtime to make use of the Adobe Media Player. Now my AS2 Flash applications can’t output to the flashlog.txt file while an AIR application is running.
This definitely didn’t happen when using the Flex Builder 3 plugin to compile AIR apps from Eclipse, before yesterday that worked fine AND my AS2 MTASC apps would still output to the flashlog.txt file.
And (naturally enough I suppose) it’s also affected my standalone Flash 8 and 7 debug players.
Apparently this is a known issue. See this blog post, this bug report at Adobe, and this unhelpful ‘no workaround’ information from Adobe.
Apparently I just need to quit my AIR application, but I was temporarily sidetracked by an AIR application that failed silently before it launched completely and kept the AIR runtime active in the background (but not visible in the Windows Task Manager). So until I restarted the computer my AS2 apps remained mute.
I’m experiencing this on Windows XP SP2 using Eclipse/MTASC and FlashTracer in Firefox, but I understand from the available info that it’s also happening on other platforms.
My mm.cfg file contains…
ErrorReportingEnable=1
TraceOutputFileEnable=1
MaxWarnings=1
If I find a solution I’ll post it here, but if you’re having a similar issue I’d appreciate a comment.
Tortoise SVN 1.5 and ANT SVN task – Format version mismatch
Caveat: I’m a Subversion newbie and probably aren’t doing things the ‘right’ way. I’m not running a Subversion server because we don’t have any Apache servers in-house and I was able to ‘just get things happening’ by creating repositories on our WIndows network using TortoiseSVN client.
Last week I upgraded my Windows Subversion client (TortoiseSVN) to the latest version (1.5.0) to see if it would play nice with our Eclipse/FDT/Subclipse setup. To begin with everything ran just fine against repositories created using TortoiseSVN 1.4.5 as well as repositories made with the new 1.5.0 client.
Today I ran an old ANT script that checks out the contents of a repository and copies a zipped version to a network location but it falied with the following message:
svn: Unable to open an ra_local session to URL
svn: Unable to open repository
svn: Expected FS format ’2′; found format ’3′
Googling found this explanation: Subversion Users: RE: FS Format Version Mismatch
So, Subclipse seems to run just fine with the new repositories but ANT doesn’t – I guess I need to look at the svnant java task and see what can be upgraded (if anything), or revert my TortoiseSVN to 1.4.1 so I’m not creating repositories that are too new for the ANT task.
I nipped over to the home of SVNAnt and got the latest release (svnant-1.1.0-RC2), then added the new files as External JARs in Eclipse’s preferences but (apart from a slightly different format to the Console output) there’s no difference in the error message.
So it looks like I’ll be reverting to TortoiseSVN 1.4.5 for the time being, unless a solution comes my way…
Note To Self: Next time this comes up, try configuring Eclipse to use the ‘system’ version of ANT by following these instructions.
[osflash] Fatal error: exception Invalid_argument("String.create")
Today I experienced a curious MTASC error using ANT to compile from Eclipse. Here’s someone else’s description of the issue…
[osflash] Fatal error: exception Invalid_argument(“String.create”)
The only solution offered (create a new Project in Eclipse and go from there) didn’t work for me at all. After a little trial and error I found that the problem disappeared when I stopped using the (client supplied) input SWF and replaced it with my own ‘known good’ input SWF.
I’m not sure of the specifics, but the client supplied SWF was full of issues. Originally it wouldn’t compile due to library ‘duplicate linkage name’ issues, and the code (all internal to the FLA) was a spaghetti nightmare. It also took about 90 seconds to ‘Test Movie’ – in my experience it’s a prime example of ‘worst practice’ Flash development.
Anyhoo, things seem to be working OK now, so I’m migrating their content into my SWF piece by piece, but at least I can compile using my ANT scripts again.










