/** * @(#) $RCSfile: FlipperPieceLoop.as,v $ $Revision: 1.4 $ $Date: 2003/03/20 14:13:06 $ * * Copyright 2003 Orgdot AS. All Rights Reserved. * http://dev.swfit.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * Loop for each flipper piece. * * @author Olaf Havnes * @version $Revision: 1.4 $ $Date: 2003/03/20 14:13:06 $ * @since SWFIT1.0 */ // Means a button has been pressed if (pos != pos_old) { if (pos < pos_old) { // Go there directly move_state = STATE_RESTING; } else { // Make sure we never go down without passing the top point. move_state = STATE_RISING; } pos_old = pos; } // Make sure we go beyond the endpoints of the conveyor belt if (move_state == STATE_RISING) { p1 = _parent.start_y; v += (p1 - p0) * RISE_AC - v * RISE_FR; p0 += v; _y = p0; moving = true; if (p0 <= _parent.start_y + 1) { move_state = STATE_FALLING; } } else if (move_state == STATE_FALLING) { p1 = _parent.end_y; v += (p1 - p0) * FALL_AC - v * FALL_FR; p0 += v; _y = p0; moving = true; if (p0 >= _parent.end_y - 1) { move_state = STATE_RESTING; } } else { p1 = eval ("../:pos_" add pos); v += (p1 - p0) * REST_AC - v * REST_FR; p0 += v; if (v * v < 0.5) { moving = false; } else { _y = int (p0); moving = true; } } // Make the button inactive when we are the current selected clip. button._visible = _parent.current != which;