Ta ai galera o arquivo para download
package br.com.webinovacoes.componentes.formularios
{
import mx.collections.ArrayCollection;
import mx.controls.Button;
import mx.controls.ComboBox;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.RemoteObject;
public class Combo extends ComboBox
{
/////////////////////////////////////////////////////////////////////////////
// Declarações
/////////////////////////////////////////////////////////////////////////////
/**
* Nome do Servico q vai preencher o combo
*/
[Bindable]
private var lista:ArrayCollection;
private var cnn:RemoteObject ;
private var _service:String;
private var upd:Button;
private var frm:Button;
/////////////////////////////////////////////////////////////////////////////
public function Combo()
{
super();
/* */
cnn= new RemoteObject();
}
override protected function createChildren():void
{
super.createChildren();
if (upd == null)
{
upd = new Button();
upd.focusEnabled = false;
upd.label=”@Embed(’../assets/Modernos/view-refresh.png’)”;
upd.x= this.width + 2;
upd.y = 2;
upd.toolTip=”Atualizar”;
addChild(upd);
}
if (frm == null)
{
frm = new Button();
frm.focusEnabled = false;
frm.x= this.width + 2;
frm.y =2;
frm.label=”@Embed(’../assets/Modernos/add_16×16.png’)”;
frm.toolTip=”Abrir cadastro”;
addChild(frm);
}
}
private var _width:Number=new Number();
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (_width==0){
_width=width;
}
// it is a little bit hardcoded but I really don’t think this is going to be changed one day
upd.setActualSize(16, 15);
frm.setActualSize(16, 15);
setActualSize(_width , height);
upd.move(_width + 2 , 2);
frm.move(_width + upd.width + 4, 2);
}
/**
* @Selecina ID
* Seleciona ID
*/
[Inspectable(category="WebInovacoes")]
public function SelecionaId(value:Number):void{
//Also ensure it is not there in the dataProvider
var att:Object = new Object();
for ( var i:Number=0;i<=dataProvider.list.length-1;i++){
att=dataProvider.getItemAt(i);
if (att.id == value){
this.selectedIndex=i;
break;
}
}
}
/**
* Função para Buscar dados no servidor
*/
[Inspectable(category="WebInovacoes")]
public function set service (value:String):void{
if(value!=null){
_service=value;
atualiza();
}
}
/**
* Função para Buscar dados no servidor
*/
[Inspectable(category="WebInovacoes")]
public function atualiza ():void{
// Carrega Combo ECF
cnn.destination = _service+”Service”;
cnn.consulta();
/* Adiciona evento */
cnn.addEventListener(
ResultEvent.RESULT,
function(event:ResultEvent):void{
lista = event.result as ArrayCollection;
dataProvider =lista;
}
);
}
}
}
Sem comentários ainda até o momento
Deixe um comentário
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>