Skip to content


ANT snippet for packaging and debugging on Samsung Smart TV

In my previous post I suggested writing ANT script for packaging debug builds for Samsung Smart TVS, but the solution wasn’t that great.

Problem came with unpacking / packing AIR file, so instead of doing that I now have a standard flash project and
package it up with ADT.

Here is what I do:

1. Create packageTemplate dir in your flash project
2. Drop config.xml
3. Drop debugger.info

Run ANT script:

Script will copy your descriptor and the swf from bin-debug, package it with ADT and copy the file to your localhost.

Only thing to do is Sync from the telly, launch Debug configuration from my previous post and launch the app on the telly.

I am not attaching .properties, it is pretty self expanatory

<?xml version="1.0" encoding="utf-8"?>
<project name="ProjectName" basedir="." default="Main">
   
        <description>Build for ProjectName</description>

        <property file="build.properties"
            description="properities for builds" />

    <target name="Main">
       
        <antcall target="copy"/>
        <antcall target="package"/>
        <antcall target="move"/>
       
    </target>
   
    <target name="copy">
        <copy todir="${basedir}/packageTemplate">
        <fileset file="bin-debug/YourProjectDescriptor-app.xml" />
        <fileset file="bin-debug/YourProjectSwf.swf" />
        </copy>
    </target>
   
    <target name="package">
        <echo>Pack</echo>
          <exec executable="java" failonerror="true" dir="packageTemplate">
                    <arg value="-Xms128m"/>
                    <arg value="-Xmx1024m"/>
                    <arg value="-jar"/>
                    <arg value="${FLEX_HOME}/lib/adt.jar"/>
                    <arg value="-package"/>
                    <arg value="-storetype"/>
                    <arg value="pkcs12"/>
                    <arg value="-keystore"/>
                    <arg value="${basedir}/certFile.p12"/>
                    <arg value="YourOutPutFileName" />
                    <arg value="YourProjectDescriptor-app.xml"/>
                    <arg value="YourProjectSwf.swf"/>
                    <arg value="config.xml"/>
                    <arg value="debugger.info"/>
               
                    <!-- This handles the prompt for 'password' from the command line. -->
                    <redirector inputstring="yourCertPassword"/>
                </exec>
        <echo>Package complete</echo>
    </target>
    <target name="move">
        <move
            file="packageTemplate/YourOutPutFileName.air"
            tofile="D:/xampp\htdocs/widgets/YourOutPutFileName.zip" />
    </target>
</project>

Posted in development.

Tagged with , , , , , , , .


Debugging AIR apps on Samsumg Smart TVs

I was trying to find anything that would allow me set up debugging for Samsung Smart TVs but I only found it wasn’t doable.
It is not true. It is possible. So I decided to write a post how to set up debugging for AIR apps on Samsung Smart TVs.

I am using Flash Builder, but my mate Huv is using IntelliJ, it is much easier to set it up with IntelliJ.
BTW kudos to Huv, for sharing the knowledge :)

So, I will briefly mention what is required (anyone doing Samsung dev should be familiar with most of the stuff).

So we have AIR project, targeting AIR 2.5 and we do a release build. Make sure you add -debug=true in compiler arguments.
Once we have the AIR file, we can pretty much scrap the AIR project.

In order to get it to work on the TV, change AIR extension to ZIP.

You Also need to include config.xml in that ZIP for it to work on Samsung telly.

Second thing you need to do is include debugger.info file that will only contain your IP address.

192.204.xxx.xxx that is the only thing the file should have.

Put both files there and copy the zip file.

Once you have that sorted, you need to set a local server ISS, apache, whatever running as your localhost.

The server should have widgetslist.xml with the location of the widgets, etc you can find more on Samsung Dev Forums on that.

So once you upload your app to the telly and are ready to run it you need to set up the debugger.

You could do it the command line way: java -jar SDK/libs/fdb.jar
run http://localhost

but wouldn’t it be way cooler to hook it up to Flash Builder console panel?

In order to get that sorted, you basically need to change the nature of your project to web application.
Flash Builder is unfortunately stupid enough to allow you to specify what to run when you have AIR app,
IntelliJ has got this decoupled.

So, the quickest way is to duplicate your project (in case you mess something up in the future)
and edit .project file to be a flash one.

Create a new project, copy the .project or just paste the following:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>XXX</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.adobe.flexbuilder.project.flexbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
    </natures>
</projectDescription>

That will make the project basic AS project again.

Once you have this running in FB, create new Debug Configuration,
Uncheck USE DEFAULT for “URL or path to launch”
and type in http://localhost

Run the debug configuration and you should see you default browser launching localhost.

Now do the standard login as “develop” 123456, Settings –> Development –> Sync.

Now you can launch the app on the TV, the app is going to use the IP from the debugger.info file to send the debug info to
and the debugger will be listening for it there.

If you did everything correctly you should see all the traces in the console panel.
Breakpoints should work too :)

If not make sure you run the debug before you launch the app on the telly.

To soothe the process I recommend writing ANT scripts that will now take your swf (from your as project)
unzip the AIR renamed to ZIP file, replace the swf in the zip file, zip in up again and copy to where your localhost is running from.

It is a bit annoying, that you cannot push to the TV directly, so to see if the change you made has resolved the issue,
you need to login as “develop” 123456, Settings –> Development –> Sync.

Apart from the sync, the rest can be nicely automated and that’s what I am gonna do now, so laterz…

Any questions give me shout.

ANT SCRIPTS HERE:

http://tomkordys.net/blog/2012/03/15/ant-snippet-for-packaging-and-debugging-on-samsung-smart-tv/

Posted in development.

Tagged with , , , , , , , , , .


Flexunit Ant Tasks, [flexunit] error while loading initial content, compiler flags and other handy stuff.

After spending almost entire day getting Flex Unit tasks sorted I decided to write what I discovered, it is really takes a bit of time to sort it out.

So I want to have an ant task that is going to execute flexunit task, that will run on a Linux without Flash Player, but will have AIR. I actually havent verified the last part because I only got it working locally.
Dropping it onto the linux box now should not be a problem.

So what do you need?
FlexUnit of course, you probably have it already if you are running unit tests, so I am not going to go there. Just make sure you have the latest version.

Ant specific documentation can be found here: http://docs.flexunit.org/index.php?title=Ant_Task

Let’s start with the version number. Make sure you have the latest version, also make sure you have the latest of taskDefinitions

You should define flex unit tasks in your build file:

<taskdef resource="flexUnitTasks.tasks"
     classpath="${FlexUnitTasks.file}"/>

Mine is pointing to “lib/flexunit/flexUnitTasks-4.1.0-8.jar”

Versioning is quite important, I was pointing to “lib/flexunit/flexUnitTasks-4.1.0-beta1.64.jar”
previously and was getting some strange errors like

[flexunit] error while loading initial content

Which only happened when I changed Flex SDK from 4.1 to 4.5.
It turns out that the beta version has got a template inside that creates default app descriptor for AIR 1.5.
Changing it to 3.1 adding version number does the job, but like I said it is probably easier to pull the latest version and not worry about the template in the jar file at all.

Once we have our tasks defined we can use flexunit tag:

<flexunit
    player="air"
    workingDir="${BIN_LOCATION.dir}"
    toDir="${BIN_LOCATION.dir}"                
    haltonfailure="false"
    verbose="true"
    localTrusted="true">
    <source dir="${SRC_ROOT.dir}" />
    <testSource dir="${TESTS_ROOT.dir}">
        <include name="**/*Test.as" />
    </testSource>
    <library dir="${BUILD_FILES.dir}" />
</flexunit>

Once again it all explained here: http://docs.flexunit.org/index.php?title=Ant_Task

If you want to add conditional compilation flags you then should go and edit your flex-config.xml or air-config in your SDK/frameworks folder

In the compiler tag add

<define>
    <name>CONFIG::LOGGING</name>
    <value>true</value>
</define>

There is a line in the docs that says:

Note: a custom built version is available that also allows you to pass compiler constants (like SOMETHING::something=something). Read about it in the discussion section (link at the top of the page).

but I did not want to go there, to get another version that potentially breaks something else. Compiler definition is good enough for me.

I also noticed some weird errors people are getting going flash route (player=”flash”).

That does look something like that

VerifyError: Error #1014: Class org.osmf.media::MediaElement could not be found.

    at flash.display::MovieClip/nextFrame()
    at mx.managers::SystemManager/deferredNextFrame()
    at mx.managers::SystemManager/preloader_preloaderDocFrameReadyHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.preloaders::Preloader/timerHandler()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

which does not occur when player is set to AIR. So overlay your Flex SDK with AIR, set the player to AIR and it should make it go away.

It was a bit time consuming checking all the versions, investigating problems I came across and hopefully with this post things will be a bit clearer.

UPDATE: If you are getting problems with UIImpersonator throwing errors make sure you point to
as3 version of flexunit swc not the flex one.

Posted in development.

Tagged with , , , , , , .


Flash builder gotcha: Main application must be in the list of application paths

Note to self
I got this weird error when I was trying to change local output folder of my project

Main application must be in the list of application paths.

Changing it from bin-debug to anything else would simply not allow me to click OK.

Solution is quite simple, you have multiple applications in one project (ie. FlexUnitApplication is a good example).

To solve the issue make sure one of the applications is set to default apps.
Right click on your main class and select “Set as default application”.
Go to properties and change your output, Ta daaaa!

Posted in development.

Tagged with , .


Good times for Flash/ITV player is out :)

Just wanted to share this with the rest of the world, that we finished working on ITV player for Android a few weeks ago.
Interesting fact is that it is entirely written in Actionscript.

Have a look yourself: http://www.itv.com/itvplayer/android/

It is only available in UK and requires WIFI to play the video, so the reviews aren’t that great, not to mention email capture at start up.

I’ve spent quite a lot of time on this and I am really happy it is live.
Could it be any better? Of course it could in loads of areas, but there is always a lot that adds into the equation (time factor, changing business requirements, costs, just to name a few). This is not the point here.

The point here is that it is entirely written in Actionscript. On top of that it utilises ITVs existing video player written in flex, that they use on their dotcom site (with a few slight changes, like controls etc.) from here :http://www.itv.com/itvplayer. I am pretty sure Android OS did’t even exist yet when this player was originally built and yet it works!

For me that proves how powerful Flash is. When we started, we obviously had a couple of challenges to overcome (at that point we were targeting AIR 2.5, which wasn’t that great). Even now performance could still be improved to make it slicker, run faster and perform better (which we are doing btw).

So what tools developers have need nowadays?
They simply need one, which is Flash Builder 4.5.
You can now target Android Phones and tablets, there is a iOs packager as well and Blackberry Playbook packager. Not to mention PCs, Macs and Linux machines:)
Pretty powerful stuff!

Testing is dead simple on devices, they are picked up by FB immediately, and emulators are also available, it is dead easy to develop.

At this point some might say, it would be better to build this app natively. Some might say Flash sucks and HTML5 is the future. I will say there is no better cost effective development than Flash. Apple fan boys and web developers I am sorry, but flash is better. Performance wise it is obvious, but it is also better cost wise. It is simply cheaper to be building things in Flash. It requires far less time than building it in anything else. It obviously has some limitations but I have faith in Adobe. I have faith they will make it better, it will run smoother and they will be fixing all those bugs in jira!

I would also say Actionscript is the best language to learn, make a living and enjoy yourself while doing it. It is very simple, it is very popular and there is a huge amount of work available out there. And thank God it is proprietary. Build it once and let Adobe worry if it works or not. I don’t care if you are using Firefox, Chrome or IE6 or if you are on a Mac or a PC or a tablet or a phone.

With Flash you can build anything from banners to complex phone apps to real time steaming video players to huge corporate banking applications with LCDS. On top of that the number of devices that now run flash/air are endless! Samsung Smart Tvs run AIR apps! Not to mention set up boxes. Flash is at core of Google TV as well as many other latest TV projects like YouView. I am pretty sure there will be more devices and platforms in the future.

There hasn’t been any better time for Flash than now. Long live Flash!

Posted in development.

Tagged with .


Working behind a proxy – solution for [java] Could not generate timestamp: Connection timed out: connect

If you are getting the following error when packaging up AIR app:

[java] Could not generate timestamp: Connection timed out: connect

means ADL cannot connect to Adobe to get the timestamp. Assuming you have internet connection it is worth checking if you don’t have to use a proxy to do so.

If you are using proxy, you need to configure JRE to use it as well and you do it in

[Adobe Flash Builder 4 folder]\jre\lib\net.properties

Simply set: java.net.useSystemProxies=true if you want to use the system proxy, or specify it manually. More instructions in the properties file.

Posted in development.


Away3d training

If you are interested in building flash sites in 3d you should definitely sign up for Away3d training with one of its founders, Rob Bateman. If you haven’t heard about Away3d yet definitely check out away3d.com.
More info on the actual training here and here

This training is part of LFPUG training, where training groups are small (max 15 ppl), venue is great and the price is only £200+VAT (lunch included!). It is really great value for money all thanks to Tink. I attended the training myself last year and I highly recommend it.

Posted in development.

Tagged with , .


Working with AIR2.0 beta and nativeProcess – walkthrough

Like I mentioned in my previous post I decided to wrap up what I’ve learned working with AIR2.0 and share it with community. Air2 beta was released 2 days before I was told to research on a scenario of running a native application along with AIR app. There are a few solutions available that can already do it and you don’t actually need to use AIR2 nativeProcess if you have similar requirement but I decided to look into AIR2 a bit closer.
Because the app is not going to be publicly available and it is going to be installed manually along with runtime (not over the web) the risk of the app misbehaving or not working at all is massively reduced. That’s only IF. The big IF was if the application is going to behave as expected and after putting a few lines of code I must admit that it does. If it hasn’t I would have probably gone with Shu or Zinc. But luckily I didn’t have to thanks to nativeProcess fuctionality available in Air2.

So, what can you do with nativeProcess? You can run any native process on user’s machine (exe for Win users, dmz for Mac).
In my case I was porting an online app to work offline and the problem was that app was heavily reliable on external services and making it work without those simply wasn’t going to work. I had to have services running on localhost and serving whatever the live service would have served. Thank God it only had to work on Windows but I will explain why later.

Prerequisites
In order to get anything done and actually to be able to test anything there are some prerequisites like I mentioned in previous post, which is getting the runtime and overlaying Flex SDK with AIR SDK. The next step is to change descriptor namespace to

xmlns="http://ns.adobe.com/air/application/2.0beta"

. The next thing in order to get access to nativeProcess is to set up one more parameter in the descriptor.

<supportedProfiles>extendedDesktop</supportedProfiles>

.
This was a really gotcha because I found one article not stating anything about it, second one stating it should already be there and doing more research I discovered it has to be added manually. That’s all what’s required to take advantage of a nativeProcess

I would expect those descriptor changes to be included in final release of AIR2. I assume the xml namespace will be generated automatically and supportedProfiles is going to be commented out like the rest of params you can set in the descriptor file.

Using nativeProcess
First thing to do is worth checking in native process is available by checking if

NativeProcess.isSupported

returns true.
If it does, the rest should look like this:

private var file : File;
private var nativeProcessStartupInfo : NativeProcessStartupInfo;
private var nativeProcess : NativeProcess;

private function preinitializeHandler(event:Event):void
{
    if (NativeProcess.isSupported)
    {
        trace("NativeProcess.isSupported");
        //get the directory
        file = File.applicationDirectory;
                // point to the file
        file = file.resolvePath("bin/mynativeProccess.exe");

                //define process startup information
        nativeProcessStartupInfo = new NativeProcessStartupInfo();
        nativeProcessStartupInfo.workingDirectory = File.applicationDirectory;
        nativeProcessStartupInfo.executable = file;
       
                //instatiate the process
        nativeProcess = new NativeProcess();
                // start the process
        nativeProcess.start(nativeProcessStartupInfo);
    }
}

Setting the workingDirectory on nativeProcessStartupInfo to be application directory is required if you need the process to know where the files are. Running the exe standalone was showing the process folder to be where it was called from, but running it through AIR was changing it to C://Documents and Settings/user folder for some strange reason.

That was it for me. I didn’t have to write any data to the process directly because my service was doing it for me. However if you need to communicate with the process you can do it.
Here is an article on how to do it:
http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html

Other thing worth mentioning is the fact that AIR will kill the process you have started when you exit the AIR application. There is no need for additional handler to kill it. You can also stop the native process anytime you like by calling

nativeProcess.exit()

.

Packaging it all up
At this stage everyting seems to be working as expected so it is time to release the app. Because I am using Eclipse with FlexBuiler plugin (3.0) I would normally do Project -> Export Release Build from the navigation, but when you are wrapping a native process this option is not available to you. You need to use ADT in order to achieve this (more on ADT here).

First thing to do would be to add FlexSDK+AIRSDK/bin folder to PATH in Environment Variables. This will allow you to type “adt” in any folder or your machine from the command line. I recommend checking you have the correct version by typing

adt - version

to see if you are using the right version of ADT. If you get “2.0.xxxxxx” you are good to go. I only realised that after a couple of attempts and I was getting really frustrated by ADT misbehaving. I was pointing to ADT in a different SDK and version of it was 1.5. This version of ADT didn’t quite understand what it had to do.

Moving forward was getting the certificate. You need it for ADT to publish an app and the easiest way to get it is simply by publishing the application through Project -> Export Release Build. There is an option there to publish certificate as well. I think that’s the easiest and quickest way to get one.

With all those tasks done, the next step is to finally run ADT and get the actual AIR application. So, from the command line, go to your bin folder of your project where your descriptor.xml and application.swf is located along the all the files you want to include (your should have your native process there) and run:

adt -package -storetype pkcs12 -keystore yourCertificate.p12
-storepass yourPassword -target
native yourApplicationName.exe
yourDescriptorFile.xml yourApplication.swf
yourFolderToInclude1 yourFileToInclude2 ...

Make sure it’s all in one line as well.

This should result in ADT spitting out yourApplicationName.exe which is a native AIR installation file. Good enough for me. I am working on a PC, I get an exe I can run, it’s all good. Hold on, what if I wanted to release it for a Mac as well? That simply wouldn’t work, it turns out I would need a mac to do it!

In my case this wouldn’t work anyways, because my nativeProcess is a service build on Microsoft .NET, but hypothetically I could have had someone written the same functionality of my native process for a Mac. Then I could do a simple check of system capabilities and launch appropriate native process dependent on that. This scenario shows how with using native process you loose the key AIR feature, which is AIR being cross-platform. “Loose” is maybe a bit too strong, but making it harder and more confusing for a developer to develop cross platform. I wonder why this is done in such a weird way without the ability to publish to multiple platforms. If you have Flex+ AIR SDK installed on your machine it means you actually have both runtimes: Win and Mac. They both sit in SDK/runtimes folder and this is what ADT needs, unless there is something else that needs including and is probably licensed. I don’t see any other explanation for this. Also worth mentioning is the fact that Adobe doesn’t mention anything on how to run a native process on Linux.

Conclusion
New features of AIR 2 are really impressive. I am particularly interested in multitouch and gestures. Native applications have also a great potential. But I am a bit concerned about security here, especially if a developer has bad intentions. Imagine you had a worm packaged with your air app or any other form of malicious crap. It does sound scary. Apart from that I don’t see anything else that would do more harm than good. The same applies to beta apart from the fact it’s only a beta.

Releasing the app as AIR2 beta app is not something I would recommend unless you will have control over the machines it will be installed on. If you release your app as Air2 beta it will only work on a machine with this specific runtime installed. The runtime will not update itself from 1.5 to 2.0 beta, like it has for example from 1.4 to 1.5 when application needed it. In order to take the advantage of those new features in 2 beta the runtime needs to be installed manually. According to Developer FAQ runtime will upgrade itself automatically only to final 2.0 runtime when it’s released but it’s got nothing to do the same with beta. Also Air 2 beta will expire.

Because you can only have 1 runtime installed if you decide to go with this beta you put at risk all other AIR apps a user can be running. I have had the beta runtime installed for over 2 weeks now, I am running a few AIR apps almost the whole time (BBC iPlayer, TweetDeck) and I haven’t noticed anything wrong with the runtime. None of the applications have never crashed or anything like it, but the fact it is only a beta proves Adobe still isn’t totally confident with it.

If you want to play with it I would highly recommend checking out release notes:
http://labs.adobe.com/wiki/index.php/AIR_2:Release_Notes
for what’s new, what the known bugs are, etc. and reading the Developer FAQ:
http://labs.adobe.com/wiki/index.php/AIR_2:Developer_FAQ

You will notice some inconsistencies in the documentation, but if you have time and enjoy investigating, it might actually be loads of fun. I really enjoyed it.

Any questions, problems, suggestions just give me a shout.

Posted in development.

Tagged with , , , , , , .


Air 2.0 beta NativeProcess.isSupported gotcha

If you wanna start playing with new AIR 2.0 there are a couple things you need:
1. Runtime
2. Air 2.0 beta SDK (installed on top of Flex SDK)
3. New app.xml descriptor namespace which is

xmlns="http://ns.adobe.com/air/application/2.0beta"

But if you want to launch a native app from air, they forgot to mention in the documentation that you need to add

<supportedProfiles>extendedDesktop</supportedProfiles>

to the same xml.

Now if you check

NativeProcess.isSupported

you should get true, which means you can run a native app. You don’t have to be packaging your air app throught ADT or do anything else to see this boolean to be true. It should work in FlexBuilder straight away. Packaging it up is probably a good material for another post. Hope that helps.

Posted in development.

Tagged with , , , .


Dependency Injection, frameworks and other latest AS3 trends, Robotlegs, Dawn, Parsley?

Attending last LFPUG meetup got me thinking about all the latest Flash and Flex development, especially in the way in which this development is going. I think the community is becoming much more mature and this can be observed by the number of frameworks that have recently poped up. Everyone is blogging about it, and you can actually get lost in all those differences each of the frameworks has. But almost all the frakeworks are build on design paterns, which is definitely a good thing. When it comes to Design Patterns it is pretty straight forward. If you don’t know what they are I suggest doing some research because using design patterns makes your code much more elegant and structured.
Here is what wikipedia says, and remember that wikipedia is ALWAYS right:

n software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

The whole article can be found here.

Bear in mind that not all the design patterns apply to AS3 because of it’s uniqueness (being an OOP language on client side, not server side). Practical use of design patterns in AS3 was well presented by Eamonn Faherty during the LFPUG’s first session. Eamonn seemed to be pretty confident talking about various patterns and I highly recommend you watch the presentation on LFPUG’s site

If that’s not enough for you, you can always get O’reilly’s book for your iPhone/iPod “Actionscript 3 Design Patterns”. Simply search for “O’reilly Design Patterns” in the app store and this book should come up. I got it myself and I find it really handly to have it will me all the time even if you are only using it to show off what cool apps have. It does the job.

Second session on Frameworks was presented by Richard Lord. Richard is well known in the flash community especially because he’s the man behind Flint, the particle system for flash. That is not the only thing Richard is well known for. Second thing is frameworks. He was even presenting on this year’s Flash on the Beach about frameworks and if you look at his blog it looks like he can call himself an expert. I didn’t make it Richards presentation on FOTB because the conference room got filled out to the max. So for those who had seen it, I recommend you watch what he presented on LFPUG because it seemed that what he added to his FOTB presentation was the most interesting stuff, mainly Parsley and Robotlegs.

I assume all of us heard of Cairngorm, PureMVC and roughty heard of Mate and Swiz.
We constantly hear to stay away from Cairngorm because it’s simply shite (although many of the people who say that have never actually used it), PureMVC is not fun to work with, Mate being only flex framework and Swiz being apparently really good but also working only with flex.

I must admit I am a fan of PureMVC because I believe days of cowboy coding are over. There has to be a unified way of writing code in this industry and PureMVC was the first one to make it happen, especially in the flash department. It’s got it’s pros and cons, but it definitely serves it’s purpose. Code in pureMVC is (usually) neatly organized and if you don’t know it, it means you are way behind.

So what is next?
To me it looks like the next big thing is Dependecy Injection and frameworks build on it. Basically all the frameworks apart from Cairngorm and PureMVC rely on DI. The easiest definition I found:

At the simplest, Dependency Injection is that act of supplying objects with their instance variables or properties. When you pass a variable to the constructor of a class, you are using Dependency Injection. When you set a property on a class, you are using Dependency Injection. If you aren’t coding your AS3 in a strictly procedural or linear fashion, the odds are that you are making use of Dependency Injection right now.

Dependecy Injection always comes with a second term Inversion Of Control. IoC container is nothing else than a container that uses DI, it’s pretty straight forward.

DI and IoC are just one of many things that came to Actioscript from other OOP languages. And I think it’s great. It means we are not re-inventing the wheel, we simply apply the best patterns, aka problem solvers from much more mature languages like Java to AS.

So, looking at what we have available in terms of DI and IoC in Actionscript are the following:

Spring Actionscript (formerly known as Prana).
Prana was the first framework using Inversion of Control for ActionScript 3.0. It was nothing else that a port of Spring Framework for Java. I have never used and I don’t think many people actually have. I think it is mosty the Java reference that puts people off but that’s just my opinion.

SmartyPants IOC
SmartyPants apart from it’s really interesting name it is the one that started the whole Dependency Injection trend. SmartyPants is not a framework itself it is only the IOC container. It is a bit verbose but it’s pretty good to get your head around DI, because it is the only thing it covers.

And here is where we come to the main reason why I wanted to write this post.

Robotlegs
Robotloegs is awesome. Robotlegs is a MVCS framework based on on Dependency Injection using Flash Events. Why MVCS? Well the author, Shaun, decided to split the model tier of the architecture into Model itself, accessed via internal API and the service where the external data is loaded into the application. Which sounds pretty resonable approach and it’s a minor change in terms of MVC approach. I personally quite like it. THe next thing you would expect is SmartyPants to handle DI. Wrong! Guys working on Robotlegs decided to write their own dependecy injection tailored to Robotlegs. And so they did giving it anoter original name SwiftSuspenders. Cool thing about Robotlegs it that you are not limited to using SwiftSuspenders. You can choose your own Dependency Injector if you don’t like the one it comes with by default. I started digging a few days ago into RobotLegs and I must admit it is really fun thing to work with.
It’s not what we had with pureMVC where you were told how to use it and that was it.
There are a lot of discussions how Robotlegs should evolve, what should be added, removed and if you have anything good to suggest, you will be heard.
I suggest you start following the Robotlegs google group.

I personally think it will be the next big framework, the pureMVC 2.0. The sooner you get into it the better. It works with Flex as well as Flash, which many of those other frameworks lack, they have no love for Flash. But is it the only solution that works with Flash as well as Flex? Certainly not.

Other player here is Parsley. Parsley has been developed by PowerFlasher, same guys who developed FDT. I haven’t played with it yet, it is definitely on my list. But following people opinions (which I don’t think is the best thing to do), I hear although it is pretty well documented, there is no community behind this framework. This is not gonna put me off but it definitely is a huge disadvantage.

Is that all?
There is one more candidate on the horizon. Probably not many people have heard about this framework. It’s called Dawn. Dawn relies on SmartyPants it’s own DI and is also inspired by Guice (just like the SmartyPants itself). If you are into checking it out, I suggest you visit their site and if you live around London, Sam, the author, will be presenting it on next FLUG on 17th of November 2009.

Summary
Robotlegs is gaining loads of momentum, it is definitely worth checking it out. I guess the whole DI stuff if fairly new and it is interesting how things are gonna go with it. But keep your eyes open on Parsley as this it the framework that apparently Adobe uses and their Caringorm 3 is pretty much gonna be like Parsley, from what I’ve heard. Also have a look at Dawn it might turn out to be also big.

If you have any questions, comments, or you disagree let me know :)

Posted in development, Uncategorized.

Tagged with , , , , , , , , , , , .