1 Reply Latest reply on Jul 14, 2009 2:02 AM by flx23

    applying easing while changing image using timer

    flx23 Level 1

      Hi

        In my app i am changing images using timer..i have 7 images when the image starts changing it flicker and background comes then the new image that is what my problem is


      here is my code..

       

                     import flash.utils.Timer;
                          import flash.events.TimerEvent;
                          import flash.display.Sprite;
                        var myTimer:Timer = new Timer(95, 7);
                      private var k:int;
                       public var imgary:Array=new Array();

       

      function init()
      {
           for(var i:int=0;i<=6;i++)
                       {
                          
                           imgary[i]=new Array();
                           imgary[i][0]="Assets/open_drawer"+i+".png";
                           if(i==1||i==2)
                           {
                               imgary[i][1]=81;
                           }
                           else if(i==0)
                           {
                               imgary[i][1]=77;
                           }
                           else if(i==3)
                           {
                                   imgary[i][1]=83;
                                   k=83;
                           }
                           else if(i==4)
                           {
                                   k=k+2;
                                   imgary[i][1]=k;
                           }
                           else
                           {
                                   k=k+3;
                               imgary[i][1]=k;
                           }
      }
           myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
                  myTimer.start();

       

      }
      public function timerHandler(e:TimerEvent):void {
                     tests.source=imgary[e.target.currentCount-1][0];
                              tests.width=383;
                              tests.height=imgary[e.target.currentCount-1][1];
                              tests.x=0;
                              //invalidateDisplayList();
                      
              }

       

          ]]>
         
         
      </mx:Script>
      <mx:Panel  verticalAlign="top" horizontalScrollPolicy="off" backgroundColor="#616060"  id="pnlMaster" width="400" height="560" horizontalCenter="-184" verticalCenter="13">
         
      <mx:Image id="tests" source="@Embed(source='Assets/drawer_img.png')" width="383"  x="0"  height="75"/>
      </mx:Panel>
      </mx:WindowedApplication>