1 Reply Latest reply on Apr 30, 2010 3:51 AM by nikos101

    Please help with  financial info <mx:itemRenderer>

    nikos101 Level 2

      I'm trying to create a list to show currencies that flash green or red depending on the fx movement. As a start I just wanted to try it with the id="ask" label but the effect I'm getting is the whole list row changes colour. Also when I mouse over a row the background goes white for that row

       

      <mx:List height="100%" width="400" dataProvider="{curData}">
              <mx:dataChange>
                  <![CDATA[
                  ]]>
              </mx:dataChange>
              <mx:itemRenderer>
                  <mx:Component>
                      <mx:HBox verticalAlign="middle" width="100%">
                          <mx:Script>
                              <![CDATA[
                                   private var oldData:Number;
                                  
                                   override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                                   {
                                   if (oldData)
                                   {
                                       super.updateDisplayList(unscaledWidth, unscaledHeight);
                                       var g:Graphics=ask.graphics;
                                        g = graphics;
                                       g.clear();
                                       if (oldData <  data.Ask)
                                       {
                                           //unmatched
                                           g.beginFill(0x00ff00);
                                           g.drawRect(0, 0, unscaledWidth, unscaledHeight);
                                           g.endFill();
                                       }
                                       else if (oldData >  data.Ask)
                                       {
                                           //matched
                                           g.beginFill(0xff0000);
                                           g.drawRect(0, 0, unscaledWidth, unscaledHeight);
                                           g.endFill();
                                       }else{
                                            g.beginFill(0xffffff);
                                           g.drawRect(0, 0, unscaledWidth, unscaledHeight);
                                           g.endFill();
                                       }
                                   }
                                   if(data){
                                      
                                   oldData = data.Ask;
                                  
                                   }
                                   }
                                 
                              ]]>
                          </mx:Script>
                          <mx:Label text="{data.Currency}" width="20%">

       

                          </mx:Label>

       

                          <mx:Label id="ask" text="{data.Ask}" width="20%">

       

                             
                          </mx:Label>
                          <mx:Label text="{data.Bid}" width="20%">

       

                          </mx:Label>
                          <mx:Label text="{data.DailyMax}" width="20%">

       

                          </mx:Label>
                          <mx:Label text="{data.DailyMin}" width="20%">

       

                          </mx:Label>

       

                      </mx:HBox>
                  </mx:Component>
              </mx:itemRenderer>

       

          </mx:List>

        • 1. Re: Please help with  financial info <mx:itemRenderer>
          nikos101 Level 2

          This resticts it to the ask label but the color never changes once its gone red or green

           

          <mx:List height="100%" width="400" dataProvider="{curData}">
                  <mx:dataChange>
                      <![CDATA[
                      ]]>
                  </mx:dataChange>
                  <mx:itemRenderer>
                      <mx:Component>
                          <mx:HBox verticalAlign="middle" width="100%">
                              <mx:Script>
                                  <![CDATA[
                                      import nikos.CommonFunctions;
                                     
                                       private var oldData:Number;
                                      
                                       override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                                       {
                                       if (oldData)
                                       {
                                           super.updateDisplayList(unscaledWidth, unscaledHeight);
                                           var g:Graphics=ask.graphics;
                                            g = graphics;
                                           g.clear();
                                           if (oldData <  data.Ask)
                                           {
                                               //unmatched
                                               g.beginFill(0x00ff00);
                                               g.drawRect(ask.x, 0, ask.width, unscaledHeight);
                                               g.endFill();
                                           }
                                           else if (oldData >  data.Ask)
                                           {
                                               //matched
                                               g.beginFill(0xff0000);
                                               g.drawRect(ask.x, 0, ask.width, unscaledHeight);
                                               g.endFill();
                                           }else{
                                           //     g.beginFill(0xffffff);
                                              // g.drawRect(ask.x, 0, ask.width, unscaledHeight);
                                          //     g.endFill();
                                           }
                                       }
                                       if(data){
                                          
                                       oldData = data.Ask;
                                      
                                       }
                                       }
                                     
                                  ]]>
                              </mx:Script>
                              <mx:Label text="{data.Currency}" width="20%">

           

                              </mx:Label>

           

                              <mx:Label id="ask" text="{data.Ask}" width="20%">

           

                                 
                              </mx:Label>
                              <mx:Label text="{data.Bid}" width="20%">

           

                              </mx:Label>
                              <mx:Label text="{data.DailyMax}" width="20%">

           

                              </mx:Label>
                              <mx:Label text="{data.DailyMin}" width="20%">

           

                              </mx:Label>

           

                          </mx:HBox>
                      </mx:Component>
                  </mx:itemRenderer>

           

              </mx:List>