September 8th, 2008 — AIR, Flex, Projects
I recently started a project of converting an older flex app to an AIR app. This app has to scan through a bunch of files, and classify certain types of media based on the location and file extension. Then it saves a manifest of the media to an xml file that can be loaded (without scanning every time).
I started out with a Kind class (think CollectionEventKind) that had the types as strings… but then I had to figure out how to store the regular expressions to make them easily accessible… Then I remembered that while everyone just uses Strings, static const vars can be any class, including it’s own class. So I came up with this class that you can use constants, or locate a specific constant. Code after the fold.
Continue reading →
September 4th, 2008 — Flex, Projects
So, this takes the long way around, and is not a good solution for mass-distributed applications, but if you’re lucky enough to have a managed environment that you can push installs down the pipe, this is a way to let your users launch files from AIR.
First, download Switchboard.
Second, add Switchboard to your libs.
Third, use this script:
private function openFile(f:File):void{
Client.init(super.applicationID);
var message:Message = new Message();
var script:String = "var runScript = function(fileName){\n" +
" var theFile = new File(fileName);\n" +
" if(!theFile.exists) return false;\n" +
" theFile.execute();\n" +
"}\n" +
"runScript(\"" + f.url.substr(7) + "\");";
message.body = script;
message.target = "bridge";
message.onError = function( msg: Message ) : void {
// put the error message into the result box
trace("Error: " + msg.body);
}
message.send();
status = “Opening ” + f.name;
Client.close();
}
This opens up bridge, then uses Bridge to run the “execute()” command that ExtendScript (or whatever they’re calling it) has available.
Now… while this is neither simple or elegant, it gets the job done. I’d rather use Merapi, but my app has to ship before Merapi can go stable.
August 29th, 2008 — Flex, Flex Code Jam
The Flex Code Jam Google Code Project is officially LIVE!
I’ve added all of our source code to the repository, including the code from the Seattle 2007 Code Jam (which is unfortunately unfinished…). We’re heading towards a 1.0 release for the Second Harvest food bank, then after 1.0 we’ll be abstracting some of the pieces, so that it can be a plug-n-play widget for any organization that wants to offer a slick location-based-search. (Though it WILL be tailored to non-profits)
The code is free to download and try out. We don’t have documentation on how to set up the AMF-PHP yet, but it’s coming… it shouldn’t be too hard, however. We have 7 open tickets as of this post, so feel free to dig in and help us release 1.0. If you work on one of the tickets, let me know… I’ll add you to the project as soon as you have code to commit.
July 29th, 2008 — Flash
Ever need to know if you’re running in debug mode (programmatically)? What screen resolution the user is running?
flash.system.Capabilities has everything you need.
<mx:Canvas visible=”{Capabilities.isDebugger}” /> will give you a canvas that is only displayed when you are debugging. You can check the flash player version, check to see if audio is enabled, many other things that can really tailor your application to enhance the user experience.
May 11th, 2008 — AIR, Flex
So… you thought you’d be cool and throw a break point on some DRAG_ENTER code, but after you’re done debugging, you’re left with a little floating icon on your desktop.

Never fear, you don’t have to restart your entire computer, open up Taskmanager and you’ll see an application called ‘Drag’. You can kill this application and the icon will disappear. If you don’t see this app, close Eclipse and find the process called ‘adl.exe’ and kill this process.
Restart averted, Yay!
February 14th, 2008 — Flex
Welcome SeaFlex’ers and other MXNA visitors. I haven’t gotten around to finishing up my article, but I’ve posted it on my BlazeDS + Flex page
It’s really a draft right now, you’ll see strikeouts and everything. Most of the content is in there, but I need to add a page or two about debugging the project, as getting an Ant-built project to debug properly in Flex can be a pain. I’ll also be adding some info about how to debug your java code at the same time you are debugging your flex code.
Take a look, and feel free to leave comments.
January 18th, 2008 — Flex, Projects
I’ve recently committed to speaking at the Seattle Flex User Group meeting in Feb, and in preparation, I will be posting my ‘notes’ here. Hopefully I will be able to take you from knowing no java to being able to have a simple yet useful application working in BlazeDS. This application will utilize Java, Hibernate and MySQL to power the Resource Manager graph from ILOG Elixir. For Java newbies like myself, I can recommend the following reading materials (I recommend signing up for OReilly Safari):
**update** I’ve moved everything to a static page, view it here: BlazeDS + Flex
Continue reading →
November 29th, 2007 — Flex
I have recently started branching my code out for multiple customers, and I needed an easy way for the Project Managers to be able to see more info about the deliverables, and be able to send that data back to me for bugfixes, feature requests, etc…
I’ve been using Ant for a while, it’s great for packaging up my Flash/AS2 applications, without including the .as, .fla, swd, etc.. files. And since so many java devs use SVN, I knew there had to be some sort of integration between the two. I eventually stumbled upon SVNANT, but was unable to get the 1.0.0 working on my machine. I found many references to 1.1.0, however, so I downloaded the source and compiled it (Thanks to Jeff at Alagad). This worked right away for me, so with the help of this post from Howard Scholtz, I was able to add in revsion #/time directly into the app without using svn keywords!
Code included after the break. Continue reading →
October 18th, 2007 — Flex
So, I’ve got some components that will need to be updated by non-programmers, so in the interest of keeping things easy to understand for them, I’m using Repeaters when I need to create multiple items based on Data (rather than creating my own component that creates these items itself through the data, which would be much more efficient, and less vexing).
So, using Repeaters creates many issues you don’t usually come in contact with. Here are some of the things I’ve run into, and the workarounds.
- Repeater.currentItem not available in the click handler
- Same as with a list and an ItemRenderer, but because I just need a button, and nothing fancy, this is annoying. I got around this by setting the “data” property (FB won’t suggest data as a property, but it’s there!) to Repeater.currentItem.
- Repeater isn’t on the display list, and doesn’t have an array of ‘children’, so it’s hard to get at the items that were created.
- A mysterious feature of Repeaters is that if you set the id of the items created, AS3 will see an array based on that ID
This means that if I use <Button id=”buttonArray” /> I will be able to do a “for each(b:Button in buttonArray)” loop to get access to those buttons. This works just like the groupName property of RadioButtons.
- Button property ’selectedField’ only gets the state, and does not set the data’s value when ’selected’ is changed.
- I’m not sure how I feel about this. Part of me expects that when the button changes to ’selected’, the data’s field should be changed too. Then the pedantic, MVC Loving part of me kicks in and wants to strangle anyone who lets the interface directly change the model… so I end up half-strangled and completely exhausted.
September 11th, 2007 — Flex
So, I’m sure it’s necessary, as bindings can happen at strange times, but null exceptions fail silently and can cause lots of debugging headaches when dealing with Data Bindings.
For me, I had forgotten to set an initialize value, so I was attempting to reach object.value, but object was null. Normally this throws an error, a quick and easy fix, but when this happens during Data Binding, no error, so you’re left scratching your head wondering why the hell your function is finishing on the 2nd line of code.
4 hours later, you look up and see that you forgot to initialize the var.