Posts Tagged ‘actionscript’

List container impedance mismatch

Friday, February 15th, 2008

Oh yeah. I forgot about this until now.

In Python, ([] == []) == True.

In ActionScript (and JavaScript and EMCAScript), ([] == []) == false.

Task number one for tomorrow: make it easy to compare Array objects using assertEquals within FlexUnit tests.

Taming and trimming FlexUnit async tests

Thursday, February 14th, 2008

I don't have time to update the HOWTOs associated with this before I end my day at the computer, but I had an ah ha! moment this evening with regard to getting FlexUnit to play nicely with RemoteObject against a PyAMF server.

Changelogs: ah ha moment, refinement and abstraction.

Files: the new test, the new class.

Some observations, where I use terminology loosely:

  • ActionScript looks superficially like Java, which is a language that I haven't used a lot, but that I've glanced at enough to notice certain patterns.

  • ActionScript is actually more like JavaScript, but has enough static typing to make it easy to follow Java idioms.

  • FlexUnit/RemoteObject samples that I've studied seem to define callback functions for asynchronous tests outside of the test case. This is unnecessary, in my opinion, and makes the test case much less readable.

    If you look at the example test above, there are five variable assignments, then a call, that comprise the entirety of the test:

    1. Line 41-42: Trigger an asynchronous operation that will produce a value object that we want to inspect.
    2. Lines 43-48: Define a function to compare the state of that object with our expectations of it.
    3. Lines 49-54: Boilerplate to connect the two together.

To me, this is a clearer way of defining tests. I hope to refine this even further by turning item 3 above into one or two lines of code.

To get to that point, my plan is to develop an API for deleting the database collection (if allowed by the server), create an empty named database, list database names, and delete a named database. That should give me enough code to figure out where the lines of fissure are to reduce that boilerplate.

Does anyone else out there know of more FlexUnit tricks? :)

Using Flex 3 without MXML, only ActionScript

Tuesday, February 12th, 2008

Using Flex 3 Component without MXML:

This post is a sample AS3 code without any MXML that enables you using Flex Component in pure AS3, initializing manually Flex Application.

This should be an excellent resource for me to use tomorrow. I'm still on my quest to learn Flex and ActionScript by way of test-driven development.

So far, I have dabbled in PyAMF enough to run a remoting server that responds to remoting client code in a Python unit test, confirming that the server side is set up correctly.

The next step is to get a FlexUnit test working that does the same operation.

Not tonight, though! :)

ActionScript mode for Aquamacs

Wednesday, February 6th, 2008

I switched to vim about a month ago, and generally enjoyed the experience using Linux.

However, even when moving my .vimrc file over, I just couldn't get comfortable using vim from the command-line, nor could I get comfortable using MacVim. I had to switch back to Aquamacs! :)

To keep myself sane with indentation while writing ActionScript code, I ran across an ActionScript mode for Emacs that worked with the latest version of Aquamacs. (The original version I found didn't work.)

To install it, I edited my ~/Library/Preferences/Aquamacs Emacs/Preferences.el file to add:

(require 'actionscript-mode)

(setq auto-mode-alist
      (append '(("\\.as$" . actionscript-mode)) auto-mode-alist))

Test-driven development in Flex

Wednesday, February 6th, 2008

I'd like to do some test-driven development in Flex right away, but I'm still looking at the options available.

The two main options seem to be ASUnit and FlexUnit.

ASUnit is the older of the two, but I think from what I've read so far I'm going to look at FlexUnit first, and if it does what I'm looking for, I'll just use it.

As far as how to get started writing tests for ActionScript code, I see there is also the corelib that Adobe is opening up, and it contains FlexUnit-based unit tests.

So, what am I looking for?

I'd like to be able to work on SchevoFlex, write tests for both the Python Side and the ActionScript side, run all of the tests at once using nose, and generally keep a fluid test-driven development cycle going... especially since part of the project is making sure we have rock-solid communications between the client and server!

Lazyweb? :)

First thoughts on Flex 3 public beta 3

Wednesday, February 6th, 2008

As I dive head-first into the world of Flex, I decided to start trial use of Flex Builder 3 public beta 3.

Although there are some incomplete areas and a few glitches, on the whole the tutorials they provided were nice introductions.

I'm pleased with the manual layout tools. I tend to like to do things "dynamically" (and that is what I'm setting out to do) but every UI designer/developer can make use of a good layout tool.

MXML is, to a Python programmer, XML. :) I've heard that you can do a lot of stuff using straight ActionScript though; that is the direction I'm going to head.

It's clear that a lot of people out there are using MXML though, and Adobe seems to be pushing it as the way to glue things together using their Flex Builder product.

So, what I'm likely to do is to lean toward the ActionScript side of things, but keep MXML handy and learn bits and pieces of it as I go along, discover what it's useful for, and figure out how to make it even more useful for what I'm using it for.