I'm trying to populate a list with icons added from a function.
If I am dataproviding the list with a model it works well and all 
the icons are added properly.
If I am dataproviding the list from a RemoteObject call, the 
functions don't respond properly and I cannot see the icons added

Any help would be great.  Thanks

The working file & Further down, the non-working file:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
width="100%" height="400">

<mx:Script>
<![CDATA[

        var iniVal:Object;
        
          [Embed(source="../../images/icon/arrow.png")]
                var selectedIcon:String;
          [Embed(source="../../images/icon/tool_ellipse.png")]
                var unselectedIcon:String;                
                
        function controlBehavior(target:Object,x:String):Void{
                switch (Number(x)){
                        case 0:
                                target.visible = true;
                                target.enabled = true;
                                break;
                        case 1:
                                target.visible = true;
                                target.enabled = false;
                                break;
                        case 2:
                                target.visible = false;
                                break;
                }
        }
                
        
        function setIcon(){
                for(var i:Number = 0; i < 
cvcaCentralAssigne.dataProvider.length; i++){
                        if(cvcaCentralAssigne.getItemAt
(i).Assignation == 1){
                                cvcaCentralAssigne.selectedIndex = i;
                                cvcaCentralAssigne.getItemAt(i).icon 
= selectedIcon;
                        }
                        else{
                                cvcaCentralAssigne.getItemAt(i).icon 
= unselectedIcon;
                        }
                }
          } 
          
        function setSelectedIcon(event){
                var currentItem = event.target.selectedIndex;

                for(var i:Number = 0; i < 
cvcaCentralAssigne.dataProvider.length; i++){
                        if(i != currentItem){
                                event.target.dataProvider.editField( 
i, 'Assignation', '0');
                        }
                }
                if(event.target.dataProvider
[currentItem].Assignation == 0){
                        event.target.dataProvider.editField( 
currentItem, 'Assignation', '1');
                }
                else if(event.target.dataProvider
[currentItem].Assignation == 1){
                        event.target.dataProvider.editField( 
currentItem, 'Assignation', '0');
                }
                setIcon();
        } 
        
]]>
</mx:Script>

<mx:Model id="myList">
        <cvcas>
                <cvca>
                        <Name>CVCA 1</Name>
                        <data>12</data>
                        <Assignation>0</Assignation>
                        <Scenario>1</Scenario>
                </cvca>
                <cvca>
                        <Name>CVCA 2</Name>
                        <data>25</data>
                        <Assignation>0</Assignation>
                        <Scenario>2</Scenario>
                </cvca>
                <cvca>
                        <Name>CVCA 3</Name>
                        <data>556</data>
                        <Assignation>1</Assignation>
                        <Scenario>3</Scenario>
                </cvca>
                <cvca>
                        <Name>CVCA 4</Name>
                        <data>12</data>
                        <Assignation>0</Assignation>
                        <Scenario>2</Scenario>
                </cvca>
        </cvcas>
</mx:Model>


<mx:Form marginBottom="0" marginTop="0" marginLeft="0" 
verticalGap="2" width="100%">
        <mx:FormItem>
                <mx:Label text="CVCA central" fontSize="12" 
fontWeight="bold"/>
        </mx:FormItem>
        <mx:FormItem id="cvcaCentralAssigneItem" marginLeft="0" 
width="737">
                <mx:List 
                                id="cvcaCentralAssigne" 
                                dataProvider="{myList.cvcas.cvca}" 
                                creationComplete="setIcon()"
                                change="setSelectedIcon(event)" 
                                
        </mx:FormItem>  
</mx:Form>

</mx:Application>

________________________________________________
___The non-working file:________________________


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
width="100%" height="400" creationComplete="initApp()">

<mx:Script>
<![CDATA[

        var iniVal:Object;
        
          [Embed(source="../../images/icon/arrow.png")]
                var selectedIcon:String;
          [Embed(source="../../images/icon/tool_ellipse.png")]
                var unselectedIcon:String;                
                
        function initApp(){
                var projectID = 190;// temp var
                var zoneID = 136;
                var mesValeurs:Object = new Object();
                mesValeurs.projectID = projectID;
                mesValeurs.zoneID = zoneID;
                ecranRO.affichageAssignation(mesValeurs);
        }  
        
        function resultHandler(result){
                iniVal = result;
        }

        function setIcon(){
                for(var i:Number = 0; i < 
cvcaCentralAssigne.dataProvider.length; i++){
                        if(cvcaCentralAssigne.getItemAt
(i).Assignation == 1){
                                cvcaCentralAssigne.selectedIndex = i;
                                cvcaCentralAssigne.getItemAt(i).icon 
= selectedIcon;
                        }
                        else{
                                cvcaCentralAssigne.getItemAt(i).icon 
= unselectedIcon;
                        }
                }
          } 
          
        function setSelectedIcon(event){
                var currentItem = event.target.selectedIndex;
                for(var i:Number = 0; i < 
cvcaCentralAssigne.dataProvider.length; i++){
                        if(i != currentItem){
                                event.target.dataProvider.editField( 
i, 'Assignation', '0');
                        }
                }
                if(event.target.dataProvider
[currentItem].Assignation == 0){
                        event.target.dataProvider.editField( 
currentItem, 'Assignation', '1');
                }
                else if(event.target.dataProvider
[currentItem].Assignation == 1){
                        event.target.dataProvider.editField( 
currentItem, 'Assignation', '0');
                }
                setIcon();
        } 

]]>
</mx:Script>

<mx:RemoteObject id="ecranRO" endpoint="@ContextRoot
()/flashservices/gateway" source="EEWizard3.cf.cvca_nf">
        <mx:method name="affichageAssignation" result="resultHandler
(event.result)"/>
</mx:RemoteObject>

<mx:Form>
        <mx:FormItem id="cvcaCentralAssigneItem" marginLeft="0" 
width="737">
                <mx:List id="cvcaCentralAssigne" 
                                dataProvider="{iniVal}" 
                                valueCommitted="setIcon()" 
                                change="setSelectedIcon(event)" 
                                />
        </mx:FormItem>  
</mx:Form>

</mx:Application>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12ha2samo/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123907524/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to