Posted tagged ‘Flex’

Useful Flex AutoComplete component

July 26, 2009

Hillel Coren made a nice auto complete text input in flex.

http://hillelcoren.com/flex-autocomplete/

Advertisements

How I write RemoteObject calls in Flex.

July 17, 2009

There are a few ways to handle responses after calling a method on one of your Flex RemoteObjects. You can define catch all result handlers in the MXML tag for your RemoteObject. You can also declare the methods you are going to call inside the MXML tag and set result handlers for each method.

The method I have found to work for me is to save the AsyncToken from a RemoteObject call and then add a responder to the token. I can do this in one line, saving me time in writing code. For example, suppose I am calling the getUsers method on my remote PHP UserManager class. I would write something like this.

AsyncToken(userManagerService.getUsers()).
addResponder(new mx.rpc.Responder(getUsers_result, fault));

I use the full path to mx.rpc.Responder since the Flex 3 compiler gives me warnings when I import mx.rpc.Responder and then use the short hand in MXML files.

How do you write your RemoteObject calls?

Styling Individual Tabs in a TabNavigator

July 1, 2009

I had to color individual tabs in a Flex TabNavigator component.  I found the solution online so I will repost it here in my own words for the benefit of myself and others.

First, you have to wait for the TabNavigator’s creationComplete event if you defined your TabNavigator’s children at compile time.  In your creationComplete event listener, you can use the getTabAt method of the TabNavigator to retrieve tabs by their index.  With the case of a TabNavigator, getTabAt returns Buttons.  So to style the first tab, you would create a style called FirstTab in your CSS file, and then write the following code:

tabNavigator.getTabAt(0).styleName = “FirstTab”;

If you create your tabs at runtime, the tabs will not be immediately available after you add children to the TabNavigator.  I found that listening for the updateComplete event for the TabNavigator and then executing getTabAt was successful.

Firefox 3.5 Private Browsing and Flex

July 1, 2009

Private browsing is useful for Flex development because it does not keep a cache.  That way, you never have to worry about whether or not you are viewing a cached version of your swf.

Flex PHP File Upload and ServiceCapture

June 24, 2009

I created a Flex form that uploads a file to a PHP script.  I kept getting a File I/O error in the Flash Player, even though I knew the URL path to the PHP script was correct.  I then closed ServiceCapture so that I could run my example in Internet Explorer, and suddenly the upload worked!  I opened Firefox, switched off the ServiceCapture proxy, and finally the upload worked in Firefox too.

It seems that the ServiceCapture proxy and the Flash Player file upload do not work well together.