Written by

  • Please see the bottom of this entry for and update to the post *

Over xmas I have been working on some examples to upload to this blog with one particular example utilising Flex Runtime Shared Libraries (RSL’s) in an ANT script.

I am very keen on the concept of RSL’s on the surface (who couldn’t be) although I have held my reservations. RSL’s sound very attractive with most online resources referring to them as a sure fire way to reduce your core application SWF size and therefore rapidly speeding up the load time within the browser. I noticed a few gaps though including: statistics on the Flex RSL’s cached within the Flash Player (of various framework releases), encryption (answered here) and which version of RSL is currently cached in the Flash Player. I am still very pro RSL’s and utilise them in my modular applications, but further testing has proved that they are not necessarily always the best option.

Read on →

Just got hit with this error again and its a silly oversight but blogging it may be of some help to someone. If your compiling your Flex application using ANT and you get the following compile-time constant error:

[compc] Error: Type was not found or was not a compile-time constant: Vector.

Then ensure you have specified a SWF version of 10 in your target-player param i.e.

build.properties

1
swf.version = 10.0.0

build.xml

1
target-player="${swf.version}"

I have delayed my upgrade to Snow Leopard on my main dev machine for ages and bit the bullet this weekend. I was pleased as punch with how straight forward things went but there were a few small niggles, one of which was that http://localhost/ fell flat on its nose. I have a few things going on with my Apache settings, one of which was to map my document root to the Sites directory so I needed to look at a couple of fixes. These two sources fixed things up a treat (thanks to both):

Mac OS X - Web Sharing

File Web Sharing

Look at Davis John’s comment:

New issue: I found that the symbolic links in the “Sites” folder weren’t being followed. I tried adding the FollowSymLinks option to my user-specific .conf file, but initially, it broke the server. I reverted, added it again and it is working correctly now. The necessary .conf file is located here:

/private/etc/apache2/users/yourusername.conf

and looks like this:

1
2
3
4
5
6
<Directory "/Users/yourusername/Sites/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Someone told me recently that they were fed up of uploading their Flex application swf to test its functionality. The reason they uploaded the swf to their remote server was to call the ColdFusion methods using RemoteObject. The process was similar to this:

  • make change to code > publish swf > upload swf to server > run swf in browser using remote url.

To make things quicker and easier you can actually access your remote services locally from within Flex by defining an endpoint to your RemoteObject:

1
2
3
4
5
6
7
<mx:RemoteObject id="myService"
       destination="ColdFusion"
       source="com.newtriks.flex.api"
       endpoint="http://yourwebhost.com/flex2gateway/"
       fault="onFault( event )"
       result="handleResult( event )"
       showBusyCursor="true" />

You can then run and debug your application locally without the need to upload the swf to the remote server.

If anyone has checked any of my PureMVC Flex examples that connect to a Remote Service (usually ColdFusion) they will notice I use a delegate class as the gateway to ColdFusion from all of my Proxies. I have recently noticed that most of my examples on line (typically named RemoteDelegate.as) usually pass an Object as a parameter for the remote request and I have not uploaded a version to accept multiple arguments in the call from the proxy to the delegate and in turn the request to ColdFusion.

Below is a link to a more flexible RemoteDelegate.as Class which now handles multiple arguments to invoke a remote request. Obviously the delegate uses RemoteObject and so can be changed to a different destination so your not limited to just ColdFusion.

An example of how to invoke the RemoteDelegate within a proxy and make a remoting call is below.

1
2
3
4
5
private var remoteDelegate:RemoteDelegate;

remoteDelegate = new RemoteDelegate( this, CF_API );

remoteDelegate.call( "cfMethod", param1, param2, param3 );

RemoteDelegate.as

  • NOTE *

Thanks to docsultant for the dynamic method invocation heads up.

I know that there are quite a few associate problems with IFrames and Flex. Unfortunately it was a must for one application I was working on. My problem arose when I re-wrapped my swf up using SWFObject. As you can see from my post I had some good help but it overrode the logic laid out by flex-iframe by hardcoding in the CSS for the iframe in the html. But as Aran quite rightly pointed out, it was down to the method in the iframe to position it correctly. After some trial and error I found the blighter that was causing the issue with IFrames in Flex whilst using SWFObject in particular.

Read on →

Once again today I downloaded a directory of classes, popped them into a project I had under SVN control and got loads of SVN related errors due to the supplier of the classes including all their .svn files with source.

I saw a cool Automator action (copied and thanks to team bkwld, I just just added Growl support instead of a text file dump) which will remove all the .svn files from a folder and its nested directories. It can be run by right clicking the folder you need to cleanup > More > Automator > ClearSVN.

Put the automator plugin into:

/Volumes/Users/{your home dir name}/Library/Workflows/Applications/Finder/

clearsvn workflow

I have had a weekend of playing around with Flex Ant Tasks and I still can’t believe that I have not submerged myself in this subject earlier. I have used Flex Ant related scripts in the past but never really dived in and had a good ol’ play in depth coding some up myself. There were a few reasons why I got my hands dirty with Flex Ant Tasks, heres two of them:

1) A more efficient method of altering the existing html-template wrapper i.e. index.template.html to use SWFObject (as does Gumbo) which didn’t involve me copying and pasting my source files into each Flex project manually each time. 2) Wanting to have a more structured build and release process for my project files in a multi developer environment.

Read on →

This is a quick post with some source code that may be of use to someone. I needed to format the Number 560 (a figure representing total pence) into pounds and pence £5.60. Obviously I needed to ensure that the decimal was in the correct place and if two digits were passed that I would have to format it appropriately to precede the digits with a zero and a decimal place i.e. £0.60. Here is the source to the 2 very small classes I use to achieve this via a static method like so:

1
2
3
4
5
6
7
8
private var exampleOne:Number = 560; // Expect £5.60
private var exampleTwo:Number = 50;  // Expect £0.50
          
public function testCurrency():void
{
      trace( CustomPriceFormatter.getPrice( exampleOne.toString(), "£" ) );
      trace( CustomPriceFormatter.getPrice( exampleTwo.toString(), "£" ) );
}

I am pleased to be a speaker at Flash Camp in Birmingham on Tuesday 16th June 2009 @ 17:00 with a topic titled Getting started with Flex & PureMVC. I will be giving an over view of the framework with a super simple lesson on setting up your Flex project utilising all the goodness of PureMVC! Also speaking are Mike Jones (Flashgen), James Whittaker (RefreshingApps), Rob Bateman (Away3D) and Enrique Duvos (Adobe Systems)!