liju1985 commented on issue #861:
URL: https://github.com/apache/royale-asjs/issues/861#issuecomment-648048969


   Ok Thank you. Dictionary i was able to replace with ObjectMap.
   
   I can see so many place collection variable is used without declaring. Any 
idea what could be it? Im just pasting mxml where it is used.
   
   <?xml version="1.0" encoding="utf-8"?>
   <mx:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009"; 
xmlns:mx="library://ns.apache.org/royale/mx">
        <fx:Script>
                <![CDATA[
                //custom combo box with support to select an item by a given 
property value match
   
                        import mx.collections.IViewCursor;
                        import mx.controls.ComboBox;
                        public var valueField:String = "value";
                        /**
                         *  lookup the item whose value equals the passed one, 
and set it as selected
                         */
                        public function set selectedValue(value:Object):void
                        {
                                if (collection && collection.length)
                                {
                                        var cursor:IViewCursor = 
collection.createCursor();
                                        while (!cursor.afterLast)
                                        {
                                                var obj:Object = cursor.current;
                                                if (obj[valueField] == value && 
obj[labelField]!=null) {
                                                        super.selectedItem = 
obj;
                                                        return;
                                                }
                                                cursor.moveNext();
                                        }
                                }
                                super.selectedIndex = 0;
                        }
                        public function get selectedValue():Object
                        {
                                return super.selectedItem[valueField];
                        }                       
                        
                        public function 
preserveDecimalLabelFn(item:Object):String {
                                var lbl:String = item.label as String;
                                if (lbl == null && !isNaN(item.label)) { // if 
it was taken as number
                                        if (parseInt(item.label)==item.label) { 
// if number is int (.0 is taken out)
                                                lbl = item.label+".0"; // add it
                                        } else {
                                                lbl = item.label+""; // else 
just convert back to string
                                        }
                                }
                                return lbl;
                        }
                ]]>
        </fx:Script>
   
   </mx:ComboBox>
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to