hasseg.org

ActionScript 3

Getting a List of Installed Fonts with Flash and Javascript

Filed under ActionScript 3, Flex, Miscallaneous, Programming

When implementing the feature in the icalBuddy examples page where the font used for the output examples could be changed interactively I needed to get a list of all the fonts installed on the current user's computer. This blog post from 2006 explains how to do it, but it refers to the deprecated ActionScript 2 API so I had to figure out how to do it with AS3.

fcshctl: the Flex Compiler Shell Controller

Filed under ActionScript 3, Flex, jEdit, Programming, Scripts

Introduction

Like I've mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe's Flex Builder IDE. This setup has worked very well for me but one annoying issue I've had to deal with because of this is the slow compilation speed: every time I make a small change into one of my projects and recompile it, the mxmlc compiler (that my build scripts are calling) has to load the JVM into memory and recompile my whole project from scratch, which obviously takes a while. Compiling things in Flex Builder is a lot faster, and the reason for that is the Flex Compiler Shell, which it uses for compilation instead of mxmlc.

Update (Version 0.5.1, Mar 17, 09):
  • Display a "compiling..." message before sending fcsh a compilation command in order to let the user know that something is going on and that they should wait instead of just killing the process.
  • If the log file exists when fcshctl runs, check if there are any other fcshctl instances running, and if not, assume that the log file has been orphaned, delete it and continue.
  • Exit with status code 0 ("ok") if fcsh output ends in the "Nothing has changed since the last compile" message.

Saving and Accessing Version/Compilation Information with Flex Applications

Filed under ActionScript 3, Flex, Programming

On several occasions while developing Flash applications I've run into problems with proxy/cache servers. The pattern is usually something like this:

  1. I notice a bug in an application that only occurs when running it on the server
  2. I debug the application, find the bug and issue a fix
  3. I deploy the new version that contains the fix onto the server
  4. I empty the browser cache and run the app on the server again, noticing that the bug seems to persist
  5. I wonder if the version I'm seeing is indeed the version that has the fix, or an older build served to me by some cache server between my workstation and the server
  6. I have to resort to stupid trickery (comparing md5 hashes of .swfs or something) in order to find out

Mac OS X Mouse Wheel Support for ActionScript 3 Flash Applications (v.2+)

Filed under ActionScript 3, Flex, Mac, Programming

AS3 Mouse Wheel support picture So I've finally updated the solution I've made earlier for enabling Mac OS X mouse wheel support in Flex applications to a second version. I didn't want to continue adding stuff into the original post, so I decided to write a separate post just for this new version. As you can see from the title, this version should work in any Flash project you're writing in ActionScript 3, as opposed to just in Flex projects. This change was contributed by Pavel Fljot, and all the other stuff I've added since have been added on top of that. Deployment should now be a lot easier and some features that were missing in the first version have also been added.

Collapsible Panel Component for Flex

Filed under ActionScript 3, Flex, Programming

Here's an another post in the same vein as my previous one: this time, the component I'm sharing is a Panel subclass that allows for collapsing and expanding its contents. What this means is that the user can click on the header of the Panel to make it toggle between an open or closed state, with a smooth animation.

Vertical TabNavigator Component for Flex

Filed under ActionScript 3, Flex, Programming

I Some time ago ran into a situation with a Flex app I was working on where I needed to use a TabNavigator component, but have its TabBar situated on the left or right side of the ViewStack (instead of on the top, where it is in the default TabNavigator.) I Could not find any workable solutions online (the ones I did find could pretty much be described as ugly hacks,) so I made my own by extending the default TabNavigator. I Submitted this component to the flexlib project, but since it has pretty much been ignored in the discussion group, I thought I'd post it here to make it available to the general public.

Update (same day as orig. post): Added simple demo and example code on how to use the component. Added comment about using embedded fonts.

ActionScript 3 Support for jEdit's SideKick Plugin Through Exuberant Ctags

Filed under ActionScript 3, Flex, jEdit, Programming

Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written ActionScript 3 support for Exuberant Ctags, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely check his stuff out if you use (or plan to use) jEdit for editing AS3.

However, after starting to use the SideKick plugin with the modified, AS3-supported version of Ctags while doing my work, I found a few small rough edges in the ActionScript support he had made:

Flex SDK Language Reference Helper Macro for jEdit

Filed under ActionScript 3, Flex, jEdit, Mac, Programming

VeryVito at turdhead.com has been writing lately about customizing jEdit for writing ActionScript, which is exactly what I've also been doing. A While ago he posted macros for referencing the help files that came with Flash CS3. Well, I don't have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I took the macro he posted and modified it so that it can be used with the Flex language reference.

Update (Oct 5, 07): Now it can search from any number of AsDoc sources
Update (Oct 8, 07): Also finds documentation for methods, changing the command for opening a file in a web browser is easier
Update (Oct 10, 07): now the script searches through files, not buffers, so you needn't have all of your project's files open for it to be able to search through them

OS X Mouse Wheel Support for Flex 2 Applications

Filed under ActionScript 3, Flex, Mac, Programming
Note: This version of this solution is deprecated. I've made a separate post about the new version, which you can find here.


In my current job I have been programming user interfaces for applications that display networks of data (as in nodes, links etc.) with the Adobe Flex framework, and the UI paradigm I have been utilizing is a kind of a Zoomable User Interface (ZUI). The idea there is to enable the user to view and manipulate objects on a two-dimensional plane, and navigate around that plane by zooming and panning.

Now, the easiest way (at least for me) to control the zooming is to use the mouse wheel. Mouse wheel support for Flex is implemented by registering an event listener of type MouseEvent.MOUSE_WHEEL with the DisplayObject that would dispatch the event. Sadly, mouse wheel support is not available in the Mac OS X version of Flash Player. This prompted me to create a custom solution, as my main computer is a MacBook and I would like to be able to test the mouse wheel navigation with my development machine.

Update: The javascript now works with more browsers than just Firefox 2 and Safari 2. I Tested it, in addition to those two, with Opera 9, Camino 1.5 and Omniweb 5.5, and it seems to work in all of them now.

Update #2: Changed the javascript code to also work with Safari 3 beta. When using it, small movements with the wheel do not invoke any action, so you'll have to roll it a bit further to make the app respond.

Update #3: Added statement about licensing the code under the MIT License as per request of Philip Flip Kromer

Update #4 (feb 8, 08): If you're looking for AS3 (not Flex) OS X mouse wheel support, check out PixelBreaker.com.

Update #5 (feb 12, 08): Fljot sent me a version of this that works also in non-Flex AS3 projects. He also fixed some issues in the code related to the automatic registration of listening objects. You can find him here.

Categories