Game Development Reference
In-Depth Information
*
*/
private function slide(event:TimerEvent):void {
// we are close enough...
// make sure the sliding delta is
// smaller than "close enough" value
if ( Math.abs(m_sprite.x - m_to.x) <= 3 &&
Math.abs(m_sprite.y - m_to.y) <= 3 ) {
m_sprite.x = m_to.x;
m_sprite.y = m_to.y;
m_timer.stop();
var e:SliderEvent;
e = new SliderEvent(SliderEvent.DONE,
false,
false,
m_userObject);
dispatchEvent(e);
return;
}
if ( m_sprite.x != m_to.x ) {
if ( m_sprite.x > m_to.x ) {
m_sprite.x -= m_deltaX;
}
else
m_sprite.x += m_deltaX;
}
if ( m_sprite.y != m_to.y ) {
if ( m_sprite.y > m_to.y ) {
m_sprite.y -= m_deltaY;
}
else
m_sprite.y += m_deltaY;
}
}
}
}
The SliderEvent is dispatched when the sliding is complete. The following is the
listing:
package pulseui.util
{
import flash.events.Event;
public class SliderEvent extends Event
 
Search WWH ::




Custom Search