Archive for the ‘flex’ Category
Tags: ActionScript 3, AS3, checker, flex, Grant Skinner, gskinner.com, spell checking, spelling, Spelling Plus Library, SPL
Posted in development, flash, flex | No Comments »
-
Monday, February 1st, 2010
Rain is a big fan of the 360 Flex conferences. We send developers every time, and have noticed the conference quality increase with each year. We are pleased to announce that we are sending 5, count them 5 speakers.
If you are considering going, I highly recommend taking part. If no other reason than to see our beautiful faces. Here is the link to register.
Here are the individuals we are sending, as well as the sessions they are teaching:


Speaker: Aaron Hardy
Title: Queue N Cache
Description: Take control of service calls by creating your own queue and dynamically shifting priority based off user interaction. Load what users are looking at first and and delay the rest for later. Show progress indicators in multiple locations for a single request. Once loaded, cache images in such a way that they can be displayed immediately anywhere in the app.


Speaker: Bryce Barrand
Title: Golden nuggets: How to find and keep top developers
Description: Part I. Even in a down economy, finding top developers is quite a task. For the most part, good people have solid jobs they love. Should you cross train? Pay hefty fees for head hunters? Monster.com? In this session we will go over a couple of options, and what we’ve found to be successful for procuring those “golden nugget” employees.
Part II: Once you have them, what makes them stay? How much does company culture make a difference? How about work load? What type of environment is cost effective for you as the employer and awesome for everybody around? We’ll also cover tips on keeping developers happy, and around for years.


Speaker: Garth Braithwaite (teaching 2 sessions)
Title: Flex 101
Description: Get up to speed on Flex quickly. We’ll be taking a full day of training to cram as much Flex 4 goodness into your head. This training is designed for those who have never used Flex.
Title: Your Flex App Looks Like Poo
Description: There is absolutely no excuse for not skinning your Flex 4 applications. We will be exploring skinning Workflows, skin requirements, and creating custom preloaders. Ultimately overhauling the interface. Although user interface design principles will be discussed, this session will not teach you how to design.


Speaker: Chase Brammer
Title: Analytics Throwdown
Description: Clients will ask, and you will be forced to choose your analytics weapon. Learn about Adomniture’s and Google’s analytics tools and how you can use them to drive business. The session will be divided up into three sections. First, the high level details about the qualities and business benefits of each. Second, a simple walk through of how to use the tools. And last, how to implement and deploy those tools in your applications.


Speaker: Gary Rogers
Title: Automated Build and Deployment Processes
Description: This session would encompass the often misunderstood methods for automating flex build and deployment cycles. Several options and examples would be concisely presented including java ant, php phing and others, as well as how to wield the power of the command line flex sdk. I would present a brief tutorial on how to get started with these methods. Also, a sophisticated GUI based build server concept would be discussed. I would also weigh the pros and cons of nightly builds and scheduled deployments and how these impact various architecture phases of an application. Also arguments discouraging the use of SVN/CVS for deployments would be presented.
In case you missed it at the beginning of the post, here is the link to register.
-
Wednesday, December 16th, 2009
Rain recently purchased a multi-seat site license for a great tool that is certain to save a lot of time and headache: Grant Skinner’s Spelling Plus Library (SPL – info here). This post describes some aspects of the implementation. You can view the source here.
The quick start documentation lists three .mxml tags to test functionality from within the application’s main .mxml file. That quickly showed us that the SPL library worked well with standard Flex components. However, due to the large scale of our application, we wanted to make sure that the functionality was available from more than just within the main .mxml file. The target property for the SpellingHighlighter.as class is bindable on the tag. So one option would be to make that property universally accessible. However, since we needed some specific behavior modification in our implementation, a wrapper class (SpellChecker.as in the .zip file below) seemed like the best option.
Many of our text components are instances of Flash’s TextField class deep within custom containers rather than standard Flex text components. SPL, however, only checks the first generation of children within a container to find a TextField. The getBiggestTextField() method in the included code digs recursively to find all available TextFields within the referenced container, grabbing the biggest one for checking.
All the rest of what the class does is contained within the inline documentation. For the robustness, ease of implementation, and extensibility of gskinner.com’s Spelling Plus Library, I’d recommend it to anyone. The only real issue right now is that it doesn’t work with Flash’s new text layout framework; I contacted them about it and they told me that that would soon be remedied.
Here’s the link:
http://blog.mediarain.com/wp-content/uploads/2009/12/splExample.pdf
Archive for the ‘flex’ Category
Tags: ActionScript 3, AS3, checker, flex, Grant Skinner, gskinner.com, spell checking, spelling, Spelling Plus Library, SPL
Posted in development, flash, flex | No Comments »
-
Wednesday, December 9th, 2009
A common thing to do in most any rich application is to show progress while loading remote assets. In ActionScript, the bytesLoaded and bytesTotal properties of classes such as LoaderInfo and URLLoader provide the needed information to show a fancy percentage-based progress indicator. The bytesLoaded property is updated as more and more of the asset is loaded in. Divide that by the bytesTotal and you have the percentage loaded.
Easy enough. How about multiple loaders? Lets say you have a group of 10 images and you’d like to show progress for all the images collectively. Because you have 10 different images you also have 10 different URLLoader instances (or Loader instances, whatever suits your fancy)–one for each image. Math would say that you divide the sum of bytesLoaded by the sum of bytesTotal and that gives you the percentage complete. Two issues arise: (more…)
Archive for the ‘flex’ Category
Tags: bytesLoaded, bytesTotal, LoaderInfo, multiple loaders, progress indicator
Posted in development, flex | 4 Comments »
-
Tuesday, September 15th, 2009
Unit testing is a topic that creates a variety of opinions. For a lot of people it is like a first date – the first time they try to take out unit testing for a spin it seems like it is fat, slow, and impedes what you want to get done. For others, it is love at first sight.
To be honest, I still struggle to decide if I want to include unit testing in my relationship with each new project I take on. I know that it is needed, and that it really is best practice, but then I get thoughts such as:
Even though I murmur about the different times to use unit testing, as Flex and Flash keep moving to become bigger players in developing true business applications, the greater the need to verify an applications functionality.
What’s cool about Flash Builder 4 and unit testing is that we finally have a solution that is actually built into the IDE. It seems that the wars between FlexUnit, FlexMonkey, Structured Log Testing, and AsUnit were won by Flex Unit when they were crowned by Adobe to be integrated in the IDE.
If you need a refresher in what unit tests are and why they are important, check this out.
So let’s take a first date with unit tests in Flash Builder 4.
1) Create a project and create a simple class that will do some business logic we want to test. In this example, we use the standard bank account example that makes deposits and withdrawals.
package
{
public class Bank
{
public function Bank() { }
private var _balance:Number;
public function get balance():Number {
return _balance;
}
public function set balance(v:Number):void {
_balance = v;
}
/**
* Deposit some money into our bank
* @param ammount
* @return
*
*/
public function deposit(ammount:Number):Number {
_balance += ammount;
return balance;
}
/**
* Withdraw some money from our bank
* @param ammount
* @return
*
*/
public function withdraw(ammount:Number):Number {
_balance -= ammount;
return balance;
}
}
}
2) Now it’s really easy to create a test case. Just right click the class you want to test and create a new test case off it:

This will name the class what it should be called (in our case BankTest.as) and insert all of your stub functions to setup/tear down the test case. You will also notice one extra file created in your directory called FlexUnitCompilerApplication. This exists simply to be the application that runs when you execute the test cases. It will also show you a nice pretty dialogue when all your tests run successfully.
3) Configure your test case. Below is a sample:
package flexUnitTests
{
import flexunit.framework.TestCase;
public class BankTest extends TestCase
{
// please note that all test methods should start with 'test' and should be public
// Reference declaration for class to test
private var classToTestRef : Bank;
public function BankTest(methodName:String=null)
{
super(methodName);
}
//This method will be called before every test function
override public function setUp():void
{
super.setUp();
classToTestRef = new Bank();
}
//This method will be called after every test function
override public function tearDown():void
{
super.tearDown();
}
/* sample test method
public function testSampleMethod():void
{
// Add your test logic here
fail("Test method Not yet implemented");
}
*/
/**
* Do a test deposit
*
*/
public function testDesposit():void {
//Reset our balance to zero
classToTestRef.balance = 0;
//An ammount to deposit
var ammount:Number = 1000;
//Deposit the ammount
classToTestRef.deposit(ammount)
//Check to make sure that this deposit posts to the balance successfully
assertEquals(ammount, ammount);
}
/**
* Do a test on a withdrawal
*
*/
public function testWithdrawal():void {
//Reset our balance to zero
classToTestRef.balance = 1000;
//An ammount to withdraw
var ammount:Number = 400;
//What the end ammount of our withdrawal should be
var endAmmount:Number = 600;
//Withdraw the ammount
classToTestRef.withdraw(ammount);
//Check to make sure that this withdrawal posts to the balance successfully
assertEquals(endAmmount, endAmmount);
}
}
}
Now just run your test! See, it’s that easy!

If you are successful, you will see two screens with the results of your tests. The first will be in the browser, but the most useful one will be right inside your IDE where you can see which tests executed successfully and which ones did not.

So there you go. That was a nice, easy first date with unit tests in Flash Builder 4!
Archive for the ‘flex’ Category
Posted in Blogroll, debugging, flash, flex | No Comments »
-
Friday, August 7th, 2009
Recently I was working on localizing a Flex project to handle multiple languages. There are a bajilion examples on the web of ways to do this, and I found a few helpful ones. The most helpful was this one.
Since the strings are changed by the client in a php admin console, the server was compiling these modules for each language I needed. So, the Flex app had to load the resource modules at run time, AND they were coming from a different domain (S3 in our case). I played with the security settings for loading a remote module as suggested by sites like this: And I was able to get my app to load the resource module from an external domain when I ran the Flex app from localhost, but when I tried to run the app locally, I kept getting this error:
“Error: Unable to load resource module from http://domainname.com/locales/en_US.swf”
I didn’t want to always debug my app from localhost, (that’s lame) so I needed a way around the Flex security restrictions.
I dug around a while looking for something to get my by, and I found people with the same error here and here. Along with one result in Russian, which I didn’t understand. Generally the answer was to load things from localhost and that should solve your issue, but like I said didn’t want to run things from localhost.
Then a beam of light crested over the horizon, licking the hopeless feelings which had me on the verge of desisting. I asked coworker, and fellow Flexer Aaron Hardy what he recommended, and he pointed me to something he had done for loading style modules. He said: “Try this. It might work” So I gave it a whirl, and BAM! It worked first try baby. So here is what I had:
private function loadLocaleResource():void
{
var eventDispatcher:IEventDispatcher =
resourceManager.loadResourceModule("FULL_URL_TO_MODULE");
eventDispatcher.addEventListener(
ResourceEvent.COMPLETE, resourceCompleteHandleer);
}
and after getting the RemoteStyleMarshaller from Aaron, this is what I changed it to:
private var moduleLoader:RemoteStyleMarshaller;
//loads the module with the locale resources
private function loadLocaleResource():void
{
moduleLoader = new RemoteStyleMarshaller("FULL_URL_TO_MODULE", false);
moduleLoader.addEventListener(StyleEvent.COMPLETE, resourceCompleteHandleer);
moduleLoader.loadStyleDeclarations();
}
You can find a full explanation of what Aaron’s class does at his blog. Basically what his RemoteStyleMarshaller does is skirt around the security settings of Flash by loading in the bytes of the module.
Hopefully this post, along with Aaron’s class will help anyone running into the same issue.
NOTE: After working through this issue with Aaron, he may post an update to his code on his site, since now it is apparent that his RemoteStyleMarshaller does more than just marshall style modules. Aaron is the hero of the day.
Archive for the ‘flex’ Category
Posted in debugging, flex | 1 Comment »
Archive for the ‘flex’ Category
Tags: 360 Flex, automated builds, flash, Flash analytics, flex, Flex caching, Flex conference, Flex skinning
Posted in Blogroll, design, development, flash, flex, php, project management | No Comments »