RSS
 

Archive for the ‘Flex’ Category

Forcing a Flex VBox to scroll when necessary

16 Jun

The VBox Flex container allows you to stack objects vertically.  If your VBox can have an unknown number of children and your app is not a fixed height, a weird behavior can occur where the VBox height expands beyond the height of it’s parent.  This usually causes scroll-bars to appear in unexpected places and possibly messes up your application layout.  Fixing this can be a nightmare of chasing down parent containers and trying to control their clipping.

Fortunately there’s a simple solution . Just set  minHeight=”0″ and it will tell the component to not expand beyond the height of it’s Parent.  This works for any container with a vertical layout as well including Panels

There’s additionally an autoLayout property which can be set to false, however I can’t get consistent results with that.  It seems like there would be some more intuitive property name to control this behavior, but at least there is a solution.

 
1 Comment

Posted in Flex

 

Adding and Removing Children from a Flex XMLList

22 Mar

I seem to always forget how this is done and for whatever reason there’s a lot of posts floating around with confusing information.  The XMLList doesn’t have any methods for adding and removing items, or even obtaining items at a specific index.  Adding and removing children from an XMLList in Flex is actually simple, though. The XMLList can be treated as if it were an Array.

// create an XML object with one child.
var parentXml:XML = ;

// parentXml.child is an XMLList.  add two new elements
parentXml.child[parentXml.child.length()] = ;
parentXml.child[parentXml.child.length()] = ;

// remove the 2nd item
delete parentXml.child[1];

Put this code inside a function and step through it in the debugger to see what’s happening.

One thing to note is that if you are binding controls to “parentXml”, the UI doens’t necessarily receive update events when the child nodes are manipulated.  In this case you may have to dispatch an event to force the UI to re-call the getter for parentXml.  Although, that is a subject for another post…

 
1 Comment

Posted in Flex

 

AIR 2 – Adobe Has Removed the Training Wheels

17 Nov

I was very excited to read Adobe’s beta release notes about AIR 2.  AIR gives developers a very easy way to develop good looking, cross-platform applications.  The problem is that, in order to ensure all applications are cross-platform, Adobe was very stingy about how much you can reach out and interact with the underlying OS.

Those of us investing time in developing AIR apps have been working with one hand tied behind our back, unable to do simple things like even launch a document in MS Word, let alone utilize the thousands of shell commands available inside the OS.  (Well, there are various alternatives and hacks to do similar things, but still…)  Simple functions like burning a CD or encoding an audio file were simply not possible because the underlying libraries that perform these functions are not accessible within the AIR sandbox – even if those libraries themselves are cross platform.  None of the other major cross-platform environments have this limitation.  AIR was designed to connect to a server via HTTP in order to do these types of things, which is great for a web-based solution but not so for a desktop solution.  So AIR sometimes gets a bad rap as a a “widget” development platform that is good for eye candy, but not able to have deep interaction with the OS.

With AIR 2 Adobe decided to lift even more of the constraints and allow developer to execute native commands.  What this means is that we might start seeing very handsome AIR apps that serve as SVN front-ends, MP3 encoders, network monitoring tools, disk utilities, etc.   AIR will be able to interact with other software on the machine such as legacy enterprise apps.  I know this was not Adobe’s original vision for AIR, but  I have always thought otherwise and I’m very glad Adobe decided to loosen the shackles.  There are several other interesting improvements in version 2, but I think the native call feature has the potential to open the floodgates for enterprise developers.

With the new functionality comes the inevitable risk that some AIR apps will only run on one platform, or they may require you to install an OS-specific component in addition to the AIR application.  It will also be possible to build an AIR app that requires a certain Windows-only or OSX-only command.  However, thoughtful developers will at least be able to make that choice for themselves.

AIR 2 is out in beta now and end users will start seeing new applications when the public release launches in the first half of 2010.

 
No Comments

Posted in AIR, Flex

 

Confusing TimeZone Offset Functionality in Flex

16 Nov

The timezone functionality in Flex (as of SDK 3.4.1) makes me wonder if this is the person who designed this behavior (I kid because I love).  It’s clear that the functionality was designed to magically handle the difficult subject of timezone and I appreciate that.  The problem is that, athough Flex goes through the trouble of calculating the UTC time automatically, you have no clean way to obtain input or display date values in anything other than the local system time.  So in order to display dates in other timezones, you actually have to enter incorrect UTC values and “trick” flex into showing the value that you want.  Additionally the remote server communication is very confusing and inconsistent with local (AIR) db storage.  The server has no way of knowing what the real value of your Date is unless you also provide it with the local clients current timezone offset.  Meanwhile, dates saved to a local DB have no timezone info stored with them at all.  Saving dates locally (AIR) can be downright dangerous if the system timezone changes while the app is open, including daylight savings changes.

If this is something that has caused you grief, I encourage you to vote for the issue to be fixed in the Flex SDK.

Read the rest of this entry »

 
8 Comments

Posted in AIR, Flex

 

Flex Remoting and WebORB Mysterious Error Messages

01 Jul

If you work with Flex remoting and WebORB, you are probably familiar with the following errors:

  • NetConnection.Call.Failed: HTTP: Status 500
  • Channel Disconnected

You may have tried directing your browser to weborb.php only to get this message: “WebORB v3.5.0 Fatal error: Call to a member function getServiceURI()”

The getServiceURI message is actually a red herring error message.  This simply occurs because weborb.php is expecting the raw headers to contain Flash remoting AMF message data.  Your browser is just making a normal HTTP GET and doesn’t know anything about AMF.   So weborb.php winds up with a null object on which it tries to call getServiceURI().  I wouldn’t be surprised to see a future release of WebORB that catches this error, even though it isn’t the purpose of this particular file to run inside a browser.

Read the rest of this entry »

 
2 Comments

Posted in AIR, Flex, PHP