I just stumbled upon such a technique last night as I was having trouble accessing array collection elements directly since I was trying to use it like an array. If you use IViewCursor class and a filter class you can achieve everything you want . You can see how I did this below. My old code was easily twice as long and non-working.
Look at the "using data providers and collections"  in the flex 3 docs.


protected var valves:ArrayCollection = new ArrayCollection([
{ptype:"exhaust",location:"cylinder 3 (right)", clearance:0.00, shimsize:000, newshimsize:000 ,newclearance:0.25}, {ptype:"exhaust",location:"cylinder 3 (left)", clearance:0.00, shimsize:000, newshimsize:000 ,newclearance:0.25}, {ptype:"exhaust",location:"cylinder 4 (right)", clearance:0.00, shimsize:000, newshimsize:000 ,newclearance:0.25}, {ptype:"exhaust",location:"cylinder 4 (left)", clearance:0.00, shimsize:000, newshimsize:000 ,newclearance:0.25}]);

private function onBikeChange(event:Event):void{
                //used to change bike clearance
                //get selected bike
                 var selected:String = ComboBox(event.target).selectedItem.data;
                 var inc:Number;
                 var exc:Number;
                 var cursor:IViewCursor;
                 var thedata:Object;
                
                        switch (selected){      
                                case "FZR400":
                                        inc = .15;
                                        exc = .25;
                                        break;
                                case "FZR600":
                                        inc = .15;
                                        exc = .25;
                                        break;
                                case "FZR1000":
                                        inc = .15;
                                        exc = .25;
                                        break;
                        }

                        // get the cursor from the array collection
                        cursor = valves.createCursor();
                        while(! cursor.afterLast){
                                if (cursor.current.ptype == "intake")
                                        cursor.current.newclearance = inc;
                                
                                if (cursor.current.ptype == "exhaust")
                                        cursor.current.newclearance = exc;
                                
                                cursor.moveNext();
                        }
        
                        valves.refresh();
        }

http://www.logicminds.biz/motorcycles/shimulator.html

Reply via email to