pretend I proof read that block of code which I copied and pasted out 
of my actual working class.

Pretend the thisEvent=eventCeil; line exists before I refer to 
eventCeil in my timer is instantiated.

Yeah... pretend.

--- In [email protected], "grae_hall" <[EMAIL PROTECTED]> wrote:
>
> I'm having a bit of a problem with the Timer function. And I'm also 
a 
> little unsure of the variable syntax to read the framerate of the 
> application.
> 
> I've created a custom class to allow me to easily attach listeners 
and 
> actions to components throughout my application in a centralised 
manner.
> 
> I've used a timer that's set to fire once per frame - which is 
worked 
> out by dividing 1000 miliseconds by the application's framerate. 
> Although at the moment I'm setting the framerate manually as I 
can't 
> quite figure out how to reference the application framerate 
dynamically.
> 
> My main problem is - that after I call a timer.reset(); before the 
> Timer has completed it's currentCount - the timer still fires one 
more 
> time.
> 
> I've tried a few things - had a bit of a stab at using 
> stopEventPropegation etc - but the syntax for that was odd and it 
never 
> worked. I tried putting in a condition for timer.running before the 
> actions I wanted to occur would be run - but the timer reports 
running 
> as true for one instance after I reset - not as soon as I reset it.
> 
> My code is here - it's unfinished, and has had a few things 
stripped 
> out for simplicities sake - but it should demonstrate what I'm 
trying 
> to acheive.
> 
> override protected function createChildren():void {
>       timer = new Timer(singleFrame, eventCeil);
>       thisEventCeil = eventCeil;
>       addListeners();
> }
> 
> private function addListeners() {
>       switch(listenerType) {
>               case "mouse":
>                       listenerTarget.hitArea = listenerHitArea;
>                       listenerTarget.addEventListener
> (MouseEvent.MOUSE_OUT, funcOutOverDown);
>                       listenerTarget.addEventListener
> (MouseEvent.MOUSE_OVER, funcOutOverDown);
>                       timer.addEventListener(TimerEvent.TIMER, 
> timerTick);
>               break;
>               case "key":
>                       trace("Key Listener Type");
>               break;
>       }
> }
> 
> private function funcOutOverDown(event:Event):void {
>       thisEventType=event.type;
>       if (timer.running) {
>               timer.reset();
>               trace("terminated timer from event listener: " + 
> lastEventVal);
>               lastEventFloor = thisEventFloor;
>               thisEventCeil = eventCeil - thisEventFloor;
>       }
>       switch(thisEventType) {
>               case "mouseOut":
>                       thisEventEaseCeil = 1;
>                       thisEventFrom = 0;
>                       thisEventTo = 1;
>                       timerInit=true;
>               break;
>               case "mouseOver":
>                       thisEventEaseCeil = undefined;
>                       thisEventTo = 1;
>                       thisEventFrom = 0;
>                       timerInit=true;
>               break;
>       }
>       if (timerInit) {
>               thisEventFloor = 0;
>               timerInit=false;
>               timer.start();
>       }
> }
> 
> private function timerTick(timerEvent:TimerEvent) {
>       trace(timerEvent);
>       if (timer.running) {
>               thisEventFloor = timer.currentCount;
>               thisEventVal = EasingLib.easeInCirc
> 
(thisEventFloor,thisEventFrom,thisEventTo,thisEventCeil,thisEventEaseC
ei
> l);
>               lastEventVal = thisEventVal;
>               if (thisEventFloor >= thisEventCeil) {
>                       trace("completed timer: " + lastEventVal 
+ " " 
> + thisEventFloor);
>                       timer.reset();
>                       lastEventFloor = thisEventFloor;
>               }
>       }
> }
> 
> The problem is - if I get an out or over event before the timer is 
> complete - which successfully resets the timer - it still passes 
the 
> timer.running condition.
> 
> That's annoying me - and I'm really not sure how to stop it from 
> occuring.
> 
> That's really the only problem I'm having at present with the code 
you 
> see - everything else seems to behave as I require it. Before I can 
> expand it out to cover more conditions and listeners I really need 
to 
> get a handle on the timer's behaviour.
> 
> I figured that getting the timer to fire once a frame and then 
process 
> my actions would be a nice non-CPU intensive way to handle my 
various 
> actions, animations etc.
> 
> I'd appreciate any input.
> 
> Cheers.
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to