There are a couple of issues I see. One, as Glen just said, is that
your timer interval is too short. The other is that you're not ending
your lines with semicolons. I'm not sure what effect that would have.
I've rewritten the code with a timer interval of 100, and traces so
you can see a history of what's in your text boxes.
Other than that, I'm not sure what your goal is. All the text fields
are being populated correctly, though it goes so fast you don't see
all the updates.
Here's the modified code:
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(100);
var timer2:Timer=new Timer(100);
var timer3:Timer=new Timer(100);
timer1.start();
timer1.addEventListener(TimerEvent.TIMER,Func_time1);
function Func_time1(e:TimerEvent):void
{
timer1txt.text=String(step);
trace("step: " + step);
step += 0.001;
}
/////Timer 2vvvvvvvvvvvv
timer2.start();
timer2.addEventListener(TimerEvent.TIMER,Func_time2);
function Func_time2(e:TimerEvent):void
{
timer2txt.text=e.target.currentCount;
trace ("timer2txt: " + timer2txt.text);
gettimertxt.text=String((getTimer()- startTime));
flagloop=true;
}
//vvvvvvvvvvvvvvvvvv/////Timer 2
timer3.start();
timer3.addEventListener(TimerEvent.TIMER,Func_time3);
function Func_time3(e:TimerEvent):void
{
timer3txt.text=e.target.currentCount;
trace ("timer3txt: " + timer3txt.text);
if((step>2) && (step<2.25))
{
if(flagloop == true)
{
testTimer();
flagloop = false;
}
}
}
///////vvvvvvvvvv////
function testTimer():void
{
flagloop=false;
for(i=0;i<10;i++)
{
trace("Hello World");
}
flagloop=true;
}
On Thu, Sep 8, 2011 at 8:50 AM, New Flashdeveloper
<[email protected]> 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]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders