Archive for the ‘Flex Development’ Category

PureMVC notes

Here are notes that I wrote down during Javier Julio's PureMVC talk at FITC Amsterdam a couple of weeks ago.  I intend to use pureMVC and they'll be a useful reference when the time arrives.  If I have glaringly misconstrued anything please let me know :-)

The Proxy and Mediator

  • The Proxy typically sends notifications
  • The Mediator receives notifications and can also send notifications
  • The Proxy is located in the Model and is a natural location for domain logic, something that tends to be wrongfully be placed in Commands
  • The Mediator performs the key task of separating the View and Model (which is the responsibility of the Controller in Cairngorm)
  • The Mediator and Proxy have a similar setup
  • Methods to override in the Mediator include;
    • listNotificationInterest(),
    • handleNotification()

About Commands:

  • Since service interaction occurs in the Proxy (located in the Model), commands in the Controller are limited to things like; startup, shutdown.
  • A Command is used when you want to do multiple things in response to a notification.
  • Mediators can directly call methods on the Proxy instead of sending a notification.  You don't have to create a Command for everything.
  • Method to override in Command
    • execute()

The Facade

  • Facade is where you retrieve, register and remove actors.
  • The Proxies, Mediators and Commands all have access to the Facade.
  • Some of the methods to override in Facade:
    • retrieveProxy(proxy)
    • registerMediator(mediator)
    • registerCommand(command)

Update:

Javier got in touch with me and kindly pointed out a couple of things that I had got wrong and also offered some encouragement.  These are a few points he made (I've made the amendments to my notes above):

"The Proxy contains controller-like code but is actually in the Model part of the architecture"

Javier - I'm not sure where you picked up this one but definitely not the case, or at least not for the Proxy. You'll find that the Mediator already acts like a controller and that can trip people up about the framework. The reason for this is that the Mediator already does the key job of separating the View Component from the Model (e.g. a or many Proxy class) thus you don't really have a huge need for commands, in fact very little. This is expected and because the Mediator essentially acts like a controller.

"...Controller are limited to things like; startup, shutdown, database calls."

Javier - I could be misunderstanding database calls here as you could mean that a Proxy that makes a call to the server to fetch data from a database but was triggered by a command. Or say an AIR app that can interact with SQLite. But things like that you want to avoid having in the Command and move into the Proxy. This is one of the big differences between PureMVC and other frameworks because by moving service interaction into the model we can achieve portability and reusability.

"Mediators can directly call methods on the Proxy instead of sending a notification sometimes.  You don't have to create a Command for everything."

Javier - Cliff Hall, the creator of PureMVC, and others, especially myself couldn't be more proud. :) You learned probably one of the most important things to take away from the presentation. A lot of people get this wrong. I use the word "wrong" as Cliff has stated very good reasons why this is not only acceptable in the framework but pushed for you to do. Don't create a command class for an action that only ever happens in one place, you are just doing more work and adding more bloat.

Posted by admin on March 11th, 2010 1 Comment

OSS Barcamp, Dublin; Slides

I gave a lightening talk on Flex using the Flash Develop IDE at OSS Barcamp in Dublin at the weekend.  It was quite a challenge fitting everything into 15 minutes but I just about managed to fit a code demo in.  Here are my slides:


It was great listening to talks and speaking with people involved in technologies other than Flash Development.  Next week I plan on attending the Drupal weekend in Galway after meeting a couple of the Drupal guys on Saturday.

Posted by admin on March 30th, 2009 2 Comments

Flash Develop and Flex Builder shortcuts comparison

I gave a presentation on Open Source Flex Development to MMUG Dublin last night and provided a shortcuts comparison between Flex Builder and Flash Develop.  It only lists the ones that I use and know about.  Feel free to mention ones that I haven't listed.


Flex Builder

Flash Develop

Description

 

 

 

Ctrl Click

F4

Jumps to class/method/property

 

Ctrl+F

Jumps to next occurrence

Ctrl+K /Ctrl+Shift+K (when text highlighted)

F3/Shift+F3

Quick find next/previous

Ctrl+F

Ctrl+H

Find and replace

Ctrl+Shift+T

Ctrl+J

Open Type dialog to jump to Class

Ctrl+O

 

Outliner

Ctrl+Shift+L

 

List of all shortcuts

Ctrl+M

Alt+Shift+Enter

Full screen the panel

 

Ctrl+M

Brings up code completion

 

Ctrl+Shift+1

Context sensitive code generator

 

Ctrl+B

Snippets menu

 

Ctrl+Shift+N

Create a copy of current file

 

F1

Google context search

 

Ctrl+Shift+K

Retrieve hexadecimal from colour dialog

Ctrl+Shift+P

Ctrl+M

Jump to matching bracket

 

Ctrl+D

Duplicate line

 

Ctrl+T

Transpose lines

 

F5/Ctrl+Enter

Test movie

 

F8

Build project

 

Ctrl+Q

Comment line

 

Ctrl+Shift+B

Comment selection

Ctrl+Shift+O

 

Organise imports

 

 

 

 

Posted by admin on March 13th, 2009 2 Comments

A thought on the options available in Flash Publishing settings

I was reading some online documentation on Adobe Labs last night about how to target Flash Player 10 Beta with Flex SDK 3.0.x.  It struck me that the approach to configuring the compiler in Flex Builder 3 could not be more disparate to how things are done in Flash CS3.  The most significant thing for me is that my version of Flex Builder 3 is future proofed (to an extent) through its ability to work with future SDK releases.

In contrast, if I want to publish my flash files to Flash Player 10 or later I will have to buy the latest version of the Flash Authoring environment.  This has always been the case with the Flash Authoring environment but wouldn’t it be great if CS3 had an equivalent feature that could be availed of when Player 10 is released?  Surely what’s good enough for developers using Flex Builder is also good enough for users of the Flash IDE or maybe I’m missing some obvious reason why the option of downloading a patch (or equivalent) doesn’t exist.

Actionscript compiler options in Flex Builder 3

- Flex Builder 3 lets you add extra Flex SDKS to the compiler options.

Posted by admin on July 16th, 2008 No Comments

Integrating Flex with Ajax

I finally got round to checking out the Flex AJAX Bridge (FABridge) over at Adobe Labs after hearing about it at MAX from Andrei Dragomir.

It essentially provides a way of making Flex components and Actionscript accessible to Javascript and vice versa.

Trying to hook up Javascript and Flash in the past has always felt very hackish-like to me and I tended to avoid it and it's security and cross-browser compatibility headaches where possible.  (Having said that, I haven't investigated the Javascript Flash Integration Kit for AS2).  FABridge appears to offer a very clean and pleasant way to integrate both technologies.  This has been my experience so far.

An additional little gem that vastly enhances the Javascript coding experience is the JSEclipse plugin for the Eclipse environment.  It provides syntax highlighting and some debugging capabilities amongst other things - I haven't delved too deeply yet but I like what I see so far!  It is definately a plugin that I can't do without now that I know about it, especially now that I'm so cosy working in Flex Builder with Actionscript.

Adding FABridge to a project couldn't be simpler in Flex Builder 3.  It's as simple as right-mouse clicking the project name in the Navigator panel and selecting 'create AjaxBridge...'

This is a screen capture from Flex Builder Beta 3 but it is slightly different to what it looks like in the feature video on Adobe Labs.

I'm not going to go into every detail here on how to use FABridge because it is documented on Adobe Labs.  What I will mention is that several files are automatically generated and you can use these files as a starting point.

directory

I've created a very simple demo that consists of several javascripts function that I dropped into ajax_demo.js;


ajax_demo.callback = function() {
alert("Hello to javascript from Flex!");
};
//associate fabridge_demo.callback with a Flash button's click event (cool!)
b_ajax_demo_root.getButton().addEventListener("click", ajax_demo.callback);
//using these in html tags
ajax_demo.getFlashText = function () {
alert("swf input text: "+b_ajax_demo_root.getTxt_input().getText());
};ajax_demo.alertme = function(){
b_ajax_demo_root.genAlert( "Hello Flex, just your ECMA cousin saying hello!" );
};

This integrates with the swf file that results from ajax_demo.mxml

Click here to see the demo. 

Here is ajax_demo.js.

Posted by admin on December 13th, 2007 No Comments