Changing Diabetes Barometer is now an Adobe MAX Semifinalist
After winning two awards last year for our “MyHome – Your Intelligent Home” and the “Nasdaq Market Replay”, it was with great interest we here at Hello Group were awaiting the email from Adobe telling us if our very cool application – “Changing Diabetes Barometer” had made it to the next level in the prestigious Adobe MAX Awards.
Today the email came, informing us that it had made it to the Semifinals… a great accomplishment thinking about some of the troubles the project had been undergoing from its inception to its transition into production, and then even some after that (as it most often is the case, I suppose).
Check it out…
http://www.changingdiabetesbarometer.com/
The system was build in Adobe Flex 3 with an architecture based on PureMVC MultiCore with a backend in .NET running a MS SQL Server 2005 and a WebORB tying it all together.
Save Image As… now as a separate tag
James Ward created a clever way of adding a “Save Image As…” feature to an image in Flex.
However clever, in my case I really wanted to avoid having to subclass the Image class specifically, so I created an MXML tag which would take the Image instance as an argument instead.
The source code looks like this…
package org.hello.saveimageas
{
import flash.events.ContextMenuEvent;
import flash.net.FileReference;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.utils.ByteArray;
import mx.controls.Image;
import mx.core.IMXMLObject;
public class SaveImageAs implements IMXMLObject
{
private var _target:Image;
private var _label:String = "Save Image As...";
public function SaveImageAs()
{
super();
}
public function initialized(document:Object, id:String):void
{
// empty for now
}
protected function saveImageAs( event:ContextMenuEvent ) : void
{
var tba:ByteArray = new ByteArray();
this.target.content.loaderInfo.bytes.readBytes(tba, 0, ( this.target.content.loaderInfo.bytes.length - 17 ) );
tba.position = 49;
var ba:ByteArray = new ByteArray();
while (tba.bytesAvailable)
{
ba.writeByte(tba.readUnsignedByte());
}
var fr:FileReference = new FileReference();
fr.save( ba, this.target.source.toString() );
}
[Bindable]
public function get target() : Image
{
return this._target;
}
public function set target( value:Image ) : void
{
this._target = value;
if( this.target != null )
{
var targetContextMenu:ContextMenu = this.target.contextMenu != null ? this.target.contextMenu : new ContextMenu();
targetContextMenu.hideBuiltInItems();
var item:ContextMenuItem = new ContextMenuItem( this.label );
targetContextMenu.customItems.push(item);
item.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, saveImageAs );
this.target.contextMenu = targetContextMenu;
}
}
[Bindable]
public function get label() : String
{
return this._label;
}
public function set label( value:String ) : void
{
this._label = value;
}
}
}
A basic usage of it could look something like this…
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:saveimageas="org.hello.saveimageas.*">
<mx:Image id="image" source="http://www.motorscooterguide.net/Pictures/cy50jog_black.jpg" />
<fx:Declarations>
<saveimageas:SaveImageAs target="{ this.image }" />
</fx:Declarations>
</s:Application>
Be sure to check out the original implementation by James Ward… it might suite your needs better…
http://www.jamesward.com/blog/2009/07/09/flex-example-right-click-save-image-as/
Thomas Burleson has already cornered this approach – as “Flex Behavior Injection”… check it out…
http://www.gridlinked.info/flex-behavior-injection/
The above modification to James Wards’ original contribution has been added to the “unsponsored” framework from where you can obtain it via SVN…
http://code.google.com/p/unsponsored/
MATE CacheSetter.. a quick and dirty introduction
One of the newer classes in the MATE Flex Framework yet to be documented is the CacheSetter.
It’s nothing overly fancy, but it does exactly what it promises… it allows you to set the Cache from an ActionTag.
Let’s examine the code below… it’s a standard MATE EventMap with a couple of eventhandlers which offers to exit an AIR application when the User clicks anywhere on it… the applications for such a feature might be quite limited, but that’s what I could think of at 4:40 AM in Bangkok after almost 2 hours of being teleconferencing with the Flex Team sitting in California and it proves the point with the CacheSetter close to a minimal implementation.
NativeSystemEventMap.mxml
<?xml version="1.0" encoding="utf-8"?>
<mate:EventMap xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"
xmlns:mate="http://mate.asfusion.com/">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import flash.desktop.NativeApplication;
]]>
</fx:Script>
<fx:Declarations>
<mate:EventHandlers type="{ FlexEvent.CREATION_COMPLETE }">
<mate:CacheSetter cacheKey="{ NativeApplication }" instance="{ NativeApplication.nativeApplication }" />
</mate:EventHandlers>
<mate:EventHandlers type="{ MouseEvent.MOUSE_DOWN }">
<mate:MethodInvoker generator="{ NativeApplication }" method="exit" />
</mate:EventHandlers>
</fx:Declarations>
</mate:EventMap>
For the sake of completion, I will also bring the code to the AIR application itself…
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:client="org.hello.micromanager.timetracker.client.*" xmlns:local="*"> <fx:Declarations> <local:NativeSystemEventMap /> </fx:Declarations> </s:WindowedApplication>
One of the more interesting and intricate details (and eventually why this exercise is interesting), is to see that it uses the Class reference as the cacheKey and that you eventually would be able to use any class or hashable object and chain as the cacheKey. If the cacheKey is NOT set explicitly it will default to use the class type of the Generator attribute, but if you are working with MATE the Cache class is one of the classes it makes the most sense to take an extra look at…
CacheSetter (Source)
http://code.google.com/p/mate-framework/source/browse/trunk/src/com/asfusion/mate/actions/CacheSetter.as
Cache (Source)
http://code.google.com/p/mate-framework/source/browse/trunk/src/com/asfusion/mate/core/Cache.as
Cache (Documentation
http://mate.asfusion.com/api_docs/com/asfusion/mate/core/Cache.html
Introducing HydraMVC…
HydraMVC is one of the most recent newcomers to the scene of Application Frameworks and Architecture Blocks for Flex Applications.
Its definitely something I’m going to check out in parallel to my love affair with the Mate Flex Framework.

HydraMVC is the result of a total rewrite of the PureMVC API exclusively for Flex, allowing Flex developers to take advantage of the PureMVC paradigm while leveraging native Flex features.
In addition to using Events vs. an independent Observer pattern, HydraMVC also streamlines implementation, encapsulating much of the initialization code that needed to be written when implementing PureMVC.
HydraMVC was written out of a love / hate relationship with PureMVC; it’s not our intent to say it’s “better” than PureMVC, because the mission of the frameworks are entirely different. PureMVC intends to be language-agnostic, where HydraMVC is a compromise by design.
While HydraMVC is an MVC framework, the demos also imply a strategy for package structure, although the implementation of HydraMVC will work regardless of whatever package structure convention you use. The goal was to create a structure that scales well for large applications, but it also allows you to quickly develop small applications in a proper MVC.
FC / FB Workflow Optimizer… sources available
I have made the sources available for the Workflow Optimizer… its a crude implementation but it does the job.
It uses Flex, AIR, as3preferenceslib, as3corelib and the Mate Flex Framework.
Don’t hesitate to comment on the ideas or concepts.. but don’t comment the code: it’s not written with any other priority than functionality…
Check it out…
http://code.google.com/p/workflowoptimizer/
Microsoft Community Day 2009 Presentation
Here is my presentation from the Microsoft Community Day 2009.
It went pretty well, I received 25 green, 12 yellow and NO red audience satisfaction reports.
Scheme: Green is GOOD, red is BAD.
Here are the sources to the code sample.. its an extremely simple and crude implementation of a Blog Reader…
http://petermolgaard.com/projects/microsoftcommunityday/MicrosoftCommunityDay_SourceFiles.zip
The “initCompleteHandler” function is protected in the FX4 DownloadProgressBar
Great news for all of us implementing Custom Preloaders…
Instead of having a private “initCompleteHandler” function on the DownloadProgressBar, the function is now protected so we can override it in custom implementations. This means that we no longer have to implement the IPreloaderDisplay interface and hack out a lot of the intended functionality in order to have the preloader also handling the load of the application logic so that it does not change to Application View until the Application is considered to actually be ready.
This is great news… making the DownloadProgressBar a lot better… now it all seems like just need some kind of “preventDefault” behavior in order to have total control over the switch from preloader to application without having to bloat the preloader itself…
Currently I am resorting to including either classes such as the PureMVC facade, a Mate eventmap or another kind of EventAggregator into the Preloader SWF in order to be able to hook into it… this is however only possible if you also hack a bit around in order to prevent the default switch from preloader to application.
Introducing… FlexBox
FlexBox is a directory of Adobe Flex Components…
…some of them are pretty cool and there is sure to be a resource or two for everyone, no matter skill-level…
Check it out…
http://flexbox.mrinalwadhwa.com/
Flex SDK 3.3 released
So finally… the long awaited Flex SDK 3.3 finally left the list of stable builds and entered the world of releases…
This is great news seeing that Flex SDK 3.2 seemed to be somewhat of a bastard and 3.3 contains a lot of fixes…
Check it out…
http://www.adobe.com/products/flex/flexdownloads/
Flex User Survey
The Flex Team at Adobe is conducting a survey for Flex Users in order to establish some general ideas about the spread and usage of Flex.
Please check it out and make yourself count in the statistics…
http://www.surveymonkey.com/s.aspx?sm=vCfoIoZ0_2bLG6CTgVcntsVA_3d_3d
It should take apr. 20 minutes to complete…








4 comments