I published today an article in InsideRia's Blog, which is a slight continuation of Encapsulating RemoteObject in Flex 4. Enjoy!

Adobe Flash Platform deserved a great event, and uniting efforts between Community and Companies, are happy of divide this event with communitys International names great, such as: Raymond Candem, Ben Forta, Terrence Ryan, Adam Lehman, Lee Brimelow, Kevin Schmidt, Liz Frederick, Charlie Arehart; and still Community National names great, such as: Neto Leal, Fabio Vedovelli, Flavio Mikami, Lauro Santos, Gabriela Perry, Fransico Paulino (Tofinha).
With the support from the Adobe Systems Inc's are going to debate about the technologies ColdFusion, Flex, AIR, Flash Media Server and LiveCycle.
BR Conference 2010 is an event created by developers for developers, with the objective of introducing to your high scale public solutions, new resources and tendencies of the market in the development of rich applications for Web and Desktop.
It is the unique opportunity of find the best professionals gathered with a common objective: argue ideas, solutions and technical involved in day by day, involving their products and clients, demonstrating in the practice as they apply the new resources of this technologies.
With the ease of customization of Flex, you can expedite the production of their applications by encapsulating internal routines (the player) or external, by creating a custom component that will be used for any application.
Here I board the DataGrid, but with the simplicity of ActionScript, you realize that you will can easily change it to other components like ComboBox, List, etc ...
RemoteDataGrid.as
The Flex.org team is available the new version of the poster.

Today Adobe announced the new versions of Flex 4 SDK and the Flex 4 that this version will be known as Flash Builder.
A longstanding demand of the ColdFusion Community, now been met, the Adobe released IDE exclusive ColdFusion called ColdFusion Builder, based on Eclipse.
Other big news is Adobe Flash Platform Services Social service, that allows Flash and Flex applications make integration with social networks with great ease.
I created an example application to manage users for groups. For that used the database MySQL and in a database with two tables (group, user). To leave of this created CFCs ORM for them, with their respective files services, which here I called DAO, then grouped all DAOs' Operations in Facade. In Flash Builder created the Pointing you the classes CFC ORM, and a ModelLocator as controler pointing destination ColdFusion contend Facade CFC.
Since my last post about Flex containing script, already does time, to break that ice, I am going to show you "the way" to automate creation forms in Flex.
/** * * @author Pedro Claudio * @see mx.events.FlexEvent */package core.events {
import flash.events.Event; import mx.events.FlexEvent; import mx.validators.EmailValidator; import mx.validators.StringValidator; public class CustomEvent extends FlexEvent
{ static public const VALIDATECHANGE:String = 'validatechange'; private var _validateType:Object; private var _validator:*; public function CustomEvent(type:String,validateType:Object, bubbles:Boolean=false,cancelable:Boolean=false)
{ super(type, bubbles,cancelable); setValidator(validateType); }
public override function clone() : Event {
return new CustomEvent(CustomEvent.VALIDATECHANGE,validateType); }
public override function toString():String {
return formatToString('CustomEvent','type', 'bubbles', 'cancelable', 'validateType','validator'); }
public function get validateType():Object {
return _validateType; }
public function get validator():*
{ return _validator; }
private function setValidator(params:Object):void
{ if(params.validateType.length < 1){
return; } _validateType = params; switch(params.validateType){
case 'string': case 'noblank': _validator = new StringValidator(); if(params.message.length > 0){
_validator.requiredFieldError = _validator.requiredFieldError = _validator.tooLongError = _validator.tooShortError = params.message; }
_validator.minLength = 1; break; case 'email': _validator = new EmailValidator(); if(params.message.length > 0){
_validator.requiredFieldError = _validator.invalidCharError = _validator.invalidDomainError =
_validator.invalidIPDomainError = _validator.invalidPeriodsInDomainError = _validator.missingAtSignError = _validator.missingPeriodInDomainError =
_validator.missingUsernameError = params.message; } break; }
_validator.source = params.source; _validator.property = params.property; _validator.required = params.required; _validator.triggerEvent = params.triggerEvent; _validator.enabled = true; } }
}
Validators are classes/tags separated of the field, to speed the development we will need the validators in the field, for that are going to manipulate a class based on TextInput (spark.components.TextInput), of form to allow of the basic configuration of validator in tag, we will work with for tag CustomInput adding these attributes, which are them: validateType that will distinguish the type of validator, message containing the text that will be sent to the navigator in case error, required characterizes as required or not. For internal manipulation were created the properties: _initialized responsible in inform if is the first time that the valitor will be created, _params responsible in the storage the configurations for the creation of validator, e _validator o validator.
/** * * @author Pedro Claudio * @see spark.components.TextInput */ package core.mxml {import core.events.CustomEvent; import core.model.CustomModelLocator; import mx.events.FlexEvent; import mx.utils.ObjectUtil; import spark.components.TextInput;
Event"validatechange", type="core.events.CustomEvent")]
public class CustomInput extends TextInput {
private var _initialized:Boolean = false; private var _params:Object = {validateType:'',message:'',source:'',index:'',property:'text',required:false,triggerEvent:'change'};
private var _validator:* ; private var _model:CustomModelLocator;
private var _validateType:String; private var _message:String = ''; private var _required:Boolean = false; private var _index:int; private var _source:String; public function CustomInput()
{ _model = CustomModelLocator.getInstance(); super(); addEventListener(FlexEvent.CREATION_COMPLETE,onCreationComplete); }
private function dispatchEventCustom():void{ _params.validateType = _validateType; _params.message = _message; _params.required = _required; _params.source = this; _params.index = _index; dispatchEvent(new CustomEvent(CustomEvent.VALIDATECHANGE,_params)); }
private function onCreationComplete(event:FlexEvent):void {
id = this.id = super.id = name; addEventListener(CustomEvent.VALIDATECHANGE,setValidator); dispatchEventCustom(); _initialized = true; }
public function get validator():* { return _validator; }
private function setValidator(event:CustomEvent):void {
enabled = true; _validator = event.validator; _model[_source][event.validateType.index].validator = event.validator;
//event.currentTarget.parent.parent.dataConfig[event.validateType.index].validator = event.validator; } public function get validateType():String
{ return _validateType; } Bindable"validatechange")] Inspectable"noblank,string,email", name='validateType')]
public function set validateType(v:String):void {
_validateType = v; if(_initialized){ dispatchEventCustom(); }
} public function get message():String {
return _message; }
Inspectable'String', name='message')]
public function set message(v:String):void {
_message = v; }
public function get source():String
{ return _source; }
Inspectable'String', name='source')]
public function set source(v:String):void {
_source = v; }
public function get required():Boolean
{ return _required; } Inspectable'Boolean', name='required')]
public function set required(v:Boolean):void {
_required = v; }
public function get index():int
{ return _index; }
public function set index(v:int):void
{ _index = v; }
}
}
The field will be created in the model of the class Form (mx.containers.Form), and as I want to let my form more generic, in other words, I want ids, labels and validadores more flexible, enabling a dynamic creation. Then it was created the tag CustomFormBase, which will receive the data for configuration of form, dynamically, in an unique property, and still will receive the action of submit (which was not worked so profoundly).
/** * * @author Pedro Claudio * @see mx.containers.Form */ package core.mxml{ import core.model.CustomModelLocator; import flash.events.MouseEvent; import mx.collections.ArrayCollection; import mx.containers.Form; import mx.controls.Alert; import mx.events.FlexEvent; import mx.validators.Validator; import spark.components.Button;
public class CustomFormBase extends Form
{ public var send:Button; private var _source:ArrayCollection; private var _model:CustomModelLocator; private var _dataConfig:String; public function CustomFormBase()
{ _model = CustomModelLocator.getInstance(); super(); addEventListener(FlexEvent.CREATION_COMPLETE,doCreationComplete); }
private function doCreationComplete(event:FlexEvent):void {
send.addEventListener(MouseEvent.CLICK,submit); } protected function submit(event:MouseEvent):void {
var _validators:Array = new Array(); for(var i:int=0;i<_source.length;i++){
_validators.push(_source[i].validator); } _validators = Validator.validateAll(_validators); if (_validators.length == 0) {
Alert.show("Preenchimento correto", "SUCCESSO"); } }
public function get source():ArrayCollection
{ return _source; } public function get dataConfig():String
{ return _dataConfig; } Bindable] Inspectable'String', name='dataConfig')]
public function set dataConfig(v:String):void {
_dataConfig = v; _source = _model[v]; }
} }
Our first MXML is very simple, using the class Repeater (mx.core.Repeater), disposing the tag of the way we wish for they are vizualizadas.
<?xml version="1.0" encoding="utf-8"?> <!-- @author Pedro Claudio @see core.mxml.CustomFormBase --> <mxml:CustomFormBase 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:mxml="core.mxml.*"><mx:Repeater id="configure" dataProvider="{source}"> <mx:FormItem label="{configure.currentItem.label}" width="100%">
<mxml:CustomInput width="100%" source="{dataConfig}" name="{configure.currentItem.id}" message="{configure.currentItem.message}" required="{configure.currentItem.required}" validateType="{configure.currentItem.validateType}" text="{configure.currentItem.text}" index="{configure.currentIndex}" />
</mx:FormItem> </mx:Repeater> <mx:FormItem width="100%" horizontalAlign="right"> <s:Button id="send" label="Submit" /> </mx:FormItem>
</mxml:CustomFormBase>
Already that we create a construction standard, we will continue in him, separating ActionScript of the MXML during the creation of the reference file of the









