Hi,

Because your timer resolution is 1ms - so you will hold up the AVM with your 1000 loop traces and your timer resolution will suffer. If you set flag_loop=true somewhere else, you maybe okay, but your logic in timer3 currently means the testTimer theoretically gets called 2 times between 2 and 2.25 seconds.

    For more useful information about how timers work in flash, check out:

    http://www.bit-101.com/blog/?p=910

    http://www.kongregate.com/forums/4/topics/83008

http://www.craftymind.com/2008/04/18/updated-elastic-racetrack-for-flash-9-and-avm2/

    Maybe google them.

It also seems your example is "theoretical" rather than a solution to a problem. If we knew what you were trying to achieve other than showing timer counts we may be able to give you some better direction.

    Glen

On 08/09/2011 15:19, New Flashdeveloper wrote:
Hi
Suppose that i set flagloop=true out side of Func_time2, mi problem is why other process have an affect on timer? If we have loop in our program it affect on timer
why is that?



------------------------------------------------------------------------
*From:* Glen Pike <[email protected]>
*To:* New Flashdeveloper <[email protected]>; Flash Coders List <[email protected]>
*Sent:* Thursday, September 8, 2011 6:25 PM
*Subject:* Re: [Flashcoders] Fw: Timer Probelem

Hi,

Your Timer delay is possibly too small to be reliable - in the documentation it says that a timer delay lower than 20ms is not recommented:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html#Timer%28%29

If you then start a loop to trace 1000 times during a timer event, this will slow down your system whilst the loop runs...

What is probably happening is that your flag_loop variable is set to true again before the loop has finished.

My question is why do you need timer3 to test the "step" variable - can't you do that in Timer1? Also timer2 seems pretty redundant - could you run a single timer that tests various conditions instead?

    HTH

    Glen

On 08/09/2011 13:50, New Flashdeveloper wrote:
>
>
>
> Hi
> I am student , I’m new in flash .In My Project I need to
> have  timer that work correctly with out
> depending on other  process in my project
> . Please look at the attachment  , one
> timer worl alone another work and have condition , when we get the condition > the timers work slowly , I don’t know why is that and how can I solve it and
> have independent  timer . I test it when
> we need to work with loop or other thing the timer stop working even the timers
> that aren’t related to it ?????????????????
>
> I have foure text box inside stage (i cant attach file because of limited size in site)
>
>
> import flash.utils.Timer;
> import flash.events.TimerEvent;
> var i :int
> var flagloop:Boolean=false;
> var step:Number=0
> var startTime :Number=getTimer()
> var timer1:Timer=new Timer(1)
> timer1.start()
> timer1.addEventListener(TimerEvent.TIMER,Func_time1)
> function Func_time1(e:TimerEvent):void
> {
>      timer1txt.text=String(step)
>      step +=0.001
>        }
>
> /////Timer 2vvvvvvvvvvvv
> var timer2:Timer=new Timer(1)
> timer2.start()
> timer2.addEventListener(TimerEvent.TIMER,Func_time2)
> function Func_time2(e:TimerEvent):void
> {
>      timer2txt.text=e.target.currentCount
>      gettimertxt.text=String((getTimer()- startTime))
>      //e.updateAfterEvent();
>      flagloop=true
> }
> //vvvvvvvvvvvvvvvvvv/////Timer 2
> var timer3:Timer=new Timer(1)
> timer3.start()
> timer3.addEventListener(TimerEvent.TIMER,Func_time3)
> function Func_time3(e:TimerEvent):void
> {
>      timer3txt.text=e.target.currentCount
>      if((step>2)&&  (step<2.25))
>      {
>          if(flagloop== true)
>          {
>              testTimer()
>          }
>              }
>    }
>
> ///////vvvvvvvvvv////
> function testTimer():void
> {
>      flagloop=false
>      for(i=0;i<1000;i++)
>      {
>          trace("Hello World")
>      }
>      flagloop=true
> }
> _______________________________________________
> Flashcoders mailing list
> [email protected] <mailto:[email protected]>
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to