Pessoal eu tenho uma tela que quero que toda vez q ela for chamada seja
feita a recarga das ArrayCollection...

A requisição esta sendo feita ao banco e os dados chegam ao Flex só que o
horizontalList não é populado, qual o problema?

ordem das chamadas: init() e o resultado cai em
:  resultFindContactTo(contactsTo:*) e depois populo o hList
fillContactImgAC()

tks
George

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns:local="*"
layout="horizontal" width="100%" height="100%" title="Call History">
 <mx:Script>
        <![CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            import mx.validators.Validator;
            import mx.controls.Label;
            import mx.managers.PopUpManager;
            import mx.containers.FormItem;
            import mx.messaging.messages.ErrorMessage;
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.events.ValidationResultEvent;
            [Bindable]
            private var myValidator:Array;
            [Bindable]
            private var contactsToImgAC:ArrayCollection = new
ArrayCollection();
            public function init():void{
                service.findContactsTo()
            }
            private function faultHandler(fault:FaultEvent):void {
                Alert.show("code:n" + fault.fault.faultCode + "nnMessage:n"
+ fault.fault.faultString + "nnDetail:n" + fault.fault.faultDetail);
            }
            private function addPhone():void {
                var phone:Phone = new Phone();
                phone.number = itxtPhone.text;
                phones.addItem(phone);
            }
            private function resetPhone():void {
                phones = selContact.phones;
            }
            private function filter():void {
                allContacts.filterFunction = filterFirst;
                allContacts.refresh();
            }
            private function filterReset():void {
                allContacts.filterFunction = null;
                allContacts.refresh();
                resetFields();
            }
            private function resetFields(): void {
                selContact = new Contact();
                phones.removeAll();
            }
            private function filterFirst(item:Object):Boolean {
                return item.name.match(new RegExp(itxtFrom.text, 'i'))
            }
            private function search():void {
                if(itxtFrom.text !='') {
                    filter();
                } else {
                    filterReset();
                }
            }
            // objs com default serve para confrontar com o em uso, para ver
se ha necessidade de update(phone e email)
            private function doSelect(c:Contact): void {
                selContact = c;
                selContactDefault = c;
                phones = c.phones;
                phonesDefault = c.phones;
            }
            private function resultFindAllContacts(contacts:*):void {
                allContacts = contacts as ArrayCollection;
            }
            private function resultFindContactTo(contactsTo:*): void {
                contactsToAC.removeAll();
    contactsToAC = contactsTo as ArrayCollection;
                fillContactImgAC();
                service.findAllContacts();
            }
            private function fillPhones():void {
                if (allContacts.length == 0)
                    return;
                phones = (allContacts.getItemAt(0) as Contact).phones;
            }
            private function fillContactImgAC():void {
                contactsToImgAC.removeAll();
                var imgO:ObjectImage;
                for each (var c:Contact in contactsToAC) {
                    imgO = new ObjectImage();
                    imgO.url = c.url_image;
                    imgO.label = c.name;
                    contactsToImgAC.addItem(imgO);
                }
            }
            private function onClickImage(imageIndex:*):void {
                selContactTo = contactsToAC.getItemAt(imageIndex) as
Contact;
            }
            private function callInformation():void{
                if(sttReturnCall.selected){
                    selCallHistory.callInformation = sttReturnCall.value as
String;
                } else if (sttPleaseCall.selected){
                    selCallHistory.callInformation = sttPleaseCall.value as
String;
                } else if(sttCallAgain.selected){
                    selCallHistory.callInformation = sttCallAgain.value as
String;
                }
            }
            private function updateCH():void {
                callInformation();

                if ((selContact.id as Object) == null)
                   service.update(selContact);
                else
                    serviceCH.update(selCallHistory);
                selContact = new Contact();
            }
            private function resultUpdateContact(contact:*):void {
                selContact = contact as Contact;
                updateCH();
            }
            private function validate():void{
            myValidator = [vldHList, vldFrom, vldEmail,vldDGPhone, vldData,
vldHora];
            var validationError:Array = Validator.validateAll(myValidator);
            if (validationError.length != 0) {
                var validatorPopUp:ValidatorPopUp = new ValidatorPopUp;
                validatorPopUp.validatorResult = validationError;
                PopUpManager.addPopUp(validatorPopUp,parent,true);
                PopUpManager.centerPopUp(validatorPopUp);
            } else {
                updateCH();
            }
  }
    ]]>
    </mx:Script>
    <mx:Validator id="vldHList" source="{hLstContactTo}" required="true"
requiredFieldError="Campo 'To' não selecionado."
                    property="selectedItem" />
    <mx:EmailValidator id="vldEmail" source="{itxtEmail}" property="text"
  required="true" triggerEvent="{Event.CHANGE}"
  requiredFieldError="É necessário informar um e-mail."
  invalidCharError="O e-mail informado não possui um formato válido."
     invalidDomainError= "O domínio de e-mail informado não possui um
formato válido."
     missingAtSignError="É necessário o simbolo [EMAIL PROTECTED] no campo 
E-mail."
     missingPeriodInDomainError="É necessário informar um domínio de
e-mail."
     missingUsernameError="É necessário informar nome de usuário de e-mail."
     tooManyAtSignsError="E-mail contém mais de um simbolo [EMAIL PROTECTED]"/>
    <mx:StringValidator id="vldFrom" source="{itxtFrom}" property="text"
                        required="true" triggerEvent="{Event.CHANGE}"
                        tooShortError="Campo inválido."
                        tooLongError="Campo inválido."
                        requiredFieldError="Campo 'From' Requerido." />
    <mx:StringValidator id="vldData" source="{dfldtime}" property="text"
                        required="true" triggerEvent="{Event.CHANGE}"
                        requiredFieldError="Campo 'Date' Requerido." />
    <mx:StringValidator id="vldHora" source="{txtHora}" property="text"
                            required="true" triggerEvent="{Event.CHANGE}"
                            requiredFieldError="Campo 'Hours' Requerido."
                            minLength="5" maxLength="5"/>
    <mx:Validator id="vldDGPhone" source="{gridPhone}" required="true"
requiredFieldError="'Phone' vazio ou não selecionado."
                    property="selectedItem" />

    <mx:RemoteObject id="service" destination="contatoService"
fault="faultHandler(event)">
  <mx:method name="findContactsTo"
result="resultFindContactTo(event.result)"/>
        <mx:method name="findAllContacts"
result="resultFindAllContacts(event.result)"/>
  <mx:method name="update" result="resultUpdateContact(event.result)"/>
 </mx:RemoteObject>
    <mx:RemoteObject id="serviceCH" destination="callHistoryService"
fault="faultHandler(event)">
        <mx:method name="update" />
    </mx:RemoteObject>
    <mx:ArrayCollection id="allContacts"/>
    <mx:ArrayCollection id="phones"/>
    <mx:ArrayCollection id="phonesDefault"/>
 <mx:ArrayCollection id="contactsToAC"/>
    <!--
    <mx:ArrayCollection id="contactsToImgAC"/>
    -->
    <local:Contact id="selContactTo" />
    <local:Contact id="selContact" name="{itxtFrom.text}"
email="{itxtEmail.text}" company="{itxtCompany.text}" phones="{phones}"
to_from="F"/>
    <local:Contact id="selContactDefault" />
    <local:CallHistory id="selCallHistory" contactFrom="{selContact}"
contactTo="{selContactTo}" history="{tareaHistory.text}" dateTime =
"{dfldtime.selectedDate}"/>
 <mx:Style>
  .txtVAlignMiddle {verticalAlign:middle}
 </mx:Style>
    <mx:VBox height="100%" width="146">
  <mx:Spacer width="10" height="10"/>
  <mx:Label text="To:" id="lblTo" width="146" textAlign="right" height="56"
styleName="txtVAlignMiddle"/>
        <mx:Spacer width="10" height="80"/>
  <mx:Label text="From:" id="lblFrom" width="100%" textAlign="right"/>
  <mx:Spacer width="100%" height="64"/>
        <mx:Label text="Company:" width="100%" textAlign="right"
id="lblCompany"/>
        <mx:Spacer width="100%" height="1"/>
  <mx:Label text="Email:" width="100%" textAlign="right" id="lblEmail"/>
  <mx:Label text="Phone:" id="lblPhone" width="100%" textAlign="right"/>
  <mx:Spacer width="100%" height="79"/>
  <mx:Label text="Date:" id="lblTime" width="100%" textAlign="right"/>
  <mx:Label text="History:" id="lblHistory" width="100%" textAlign="right"/>
        <mx:Spacer width="100%" height="26"/>
        <mx:Label text="Status:" id="lblStatus" width="100%"
textAlign="right"/>
    </mx:VBox>
 <mx:VBox height="100%" width="622">
  <mx:Spacer width="10" height="10"/>
  <mx:HorizontalList id="hLstContactTo" dataProvider="{contactsToImgAC}"
useHandCursor="true" itemRenderer="ImageItemRenderer" width="100%"
height="140" click="onClickImage(hLstContactTo.selectedIndex)"/>
  <mx:HBox width="100%" id="hboxFrom">
   <mx:TextInput width="246" id="itxtFrom" change="search()"
text="{selContact.name}"/>
            <mx:Button label="Clear" id="btnClearContact"
click="filterReset()"/>
  </mx:HBox>
  <mx:DataGrid height="60" id="gridFrom" width="100%"
dataProvider="{allContacts}"
itemClick="doSelect(Contact(event.currentTarget.selectedItem))">
   <mx:columns>
    <mx:DataGridColumn headerText="Contact" dataField="name" width="100"/>
    <mx:DataGridColumn headerText="Company" dataField="company"
width="100"/>
   </mx:columns>
  </mx:DataGrid>
        <mx:TextInput width="246" id="itxtCompany"
text="{selContact.company}"/>
  <mx:TextInput width="246" id="itxtEmail" text="{selContact.email}"/>
  <mx:HBox width="100%">
   <mx:TextInput id="itxtPhone" width="246"/>
            <mx:Button label="Add" id="btnAddPhone" click="addPhone()"/>
   <mx:Button label="Clear" id="btnClearPhone" click="resetPhone()"/>
  </mx:HBox>
        <mx:DataGrid width="247" height="72" id="gridPhone"
dataProvider="{phones}">
   <mx:columns>
    <mx:DataGridColumn headerText="Number" dataField="number"/>
   </mx:columns>
  </mx:DataGrid>
  <mx:HBox>
            <mx:DateField id="dfldtime"/>
            <mx:Label text="Hours:" />
            <mx:TextInput id="txtHora" width="50" maxChars="5"/>
        </mx:HBox>
        <mx:TextArea width="100%" id="tareaHistory"/>
        <mx:HBox width="100%" height="100%" id="hboxStatus">
            <mx:RadioButton groupName="rbStatus" id="sttReturnCall"
selected="true" value="Retornou Ligacao" label="Return Call"
click="callInformation()" />
            <mx:RadioButton groupName="rbStatus" id="sttPleaseCall"
value="Favor Ligar" label="Please Call" click="callInformation()" />
            <mx:RadioButton groupName="rbStatus" id="sttCallAgain"
value="Ligar Novamente" label="Will Call Again" click="callInformation()" />
        </mx:HBox>
        <mx:HBox width="100%" height="100%">
   <mx:Spacer width="40%" height="10"/>
   <mx:Image source="img/Ok(reduzido).png" toolTip="Confirm" id="imgConfirm"
enabled="false" click="validate()"/>
   <mx:Image source="img/cancel(reduzido).png" toolTip="Cancel"
id="imgCancel"/>
  </mx:HBox>
 </mx:VBox>

</mx:Panel>

--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
Para sair da lista, envie um email em branco para [EMAIL PROTECTED]
Mais opções estão disponíveis em http://groups.google.com/group/flexdev
-~----------~----~----~----~------~----~------~--~---

Responder a