[Golist] START event not dispatched when playing delayed LinearGo second time

Stephen Downs steve at plasticbrain.com
Mon Sep 29 13:35:31 PDT 2008


There seems to be a conditional logic error in way the GoEvent.START  
is dispatched in LinearGo. This occurs when playing a delayed  
LinearGo, pausing it after it starts, then using skipTo(0), pause, and  
then resume to start it once again.

Setup:
	LinearGo with delay 2.5, duration 3

Steps to replicate:
1) Start the LinearGo.
2) Pause play at the 4 second mark (in the middle of the animation).
3) Call skipTo(0), followed immediately by pause() and resume() (to  
mimic user-based random navigation access).

Expected results:
LinearGo should issue a START event 2.5 seconds after step 3, and  
change it's state to PLAYING.

Actual results:
LinearGo does not issue a START event at the 2.5 second mark, and  
leaves it's state set to PLAYING_DELAY.


Workaround:
Since the update function deals with changing the _state, I've popped  
in a kludge fix there on my LinearGo extended class, as follows:


override public function update(currentTime:Number) : void {
			if (_state==PlayStates.PAUSED)
				return;
			
			_currentFrame ++;
			if (_useFrames)
				currentTime = _currentFrame;
			
			if (isNaN(_startTime))		// setup() must be called once prior to  
tween's 1st update.
				setup(currentTime);		// This is done here, not in start, for  
tighter syncing of items.
			
			if (_startTime > currentTime) {
				// ::kludge:: Here is my crummy fix.
				if (_started) {
					_started = false;
				}
				return; // still PlayStates.PLAYING_DELAY
			}
			
			// (1.) Set _position and determine primary update type.
			var type:String = GoEvent.UPDATE;
			if (currentTime < _endTime) { // start, update...
				if (!_started)
					type = GoEvent.START;
				var time:Number = _easeParams[0] = (currentTime - _startTime);
				_position = _currentEasing.apply(null, _easeParams); // update  
position using easing function.
				if (_position==2.220446049250313e-16) { _position = 0; }//  
Corrects for a computer rounding error in Back.easeOut() at position 0.
			}
			else { // complete, cycle...
				_position = _easeParams[1] + _change; // set absolute 1 or 0  
position at end of cycle
				type = (_repeater.hasNext() ? GoEvent.CYCLE : GoEvent.COMPLETE);
			}
			
			// (2.) Run onUpdate() passing the primary update type, then
			// (3.) dispatch up to three events in correct order.
			onUpdate(type);
			if (!_started) {
				_state = PlayStates.PLAYING;
				_started = true;
				dispatch(GoEvent.START);
			}
			dispatch(GoEvent.UPDATE);
			if (type==GoEvent.COMPLETE) {
				stop();
				dispatch(GoEvent.COMPLETE);
			}
			else if (type==GoEvent.CYCLE) {
				_repeater.next();
				dispatch(GoEvent.CYCLE);
				_startTime = NaN; // causes setup() to be called again on next  
update to prep next cycle.
			}
		}


////////////////


I'm sure this is an inelegant patch, possibly impacting other  
functionality, but it gets me were I need to be for now.

Steve




More information about the GoList mailing list