RE: [flexcoders] Re: Timer problems - timer still firing once after timer is reset.

2006-03-27 Thread Matt Chotin
The frameRate is available on the Stage which you can reach through a
DisplayObject.

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of grae_hall
Sent: Wednesday, March 22, 2006 1:00 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Timer problems - timer still firing once after
timer is reset.

Well - fortunately the request for thoughts on the timer can be 
disregarded - I've managed to get it all working. The application now 
has a custom class able to be attached to any interface component which 
tweens from a user defined value to a user defined value with a user 
defined easing type. If related listener events are fired while a tween 
is in progress, the class tweens back from the current value to the 
destination value defined in the most recently fired listener - in the 
same number of frames it took to get to its current value.

I had no luck with this basic type of interface functionality using the 
native flex classes - which is a little disappointing.

I'm still having difficulties getting the value of the application 
framerate. So any tips there would be appreciated.






--
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



 




--
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/
 




[flexcoders] Re: Timer problems - timer still firing once after timer is reset.

2006-03-22 Thread grae_hall
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 flexcoders@yahoogroups.com, 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:

[flexcoders] Re: Timer problems - timer still firing once after timer is reset.

2006-03-22 Thread grae_hall
Well - fortunately the request for thoughts on the timer can be 
disregarded - I've managed to get it all working. The application now 
has a custom class able to be attached to any interface component which 
tweens from a user defined value to a user defined value with a user 
defined easing type. If related listener events are fired while a tween 
is in progress, the class tweens back from the current value to the 
destination value defined in the most recently fired listener - in the 
same number of frames it took to get to its current value.

I had no luck with this basic type of interface functionality using the 
native flex classes - which is a little disappointing.

I'm still having difficulties getting the value of the application 
framerate. So any tips there would be appreciated.






--
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/