Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.84k stars 819 forks source link

Juggler.removeDelayedCalls function doesn't remove the id of delayed call. #930

Closed AndrewNeuronation closed 7 years ago

AndrewNeuronation commented 7 years ago

Hello Daniel.

After updating to Starling 2 we noticed strange behavior while using remove() function to remove delay call from Juggler. Sometimes we get range error #1125.

After some investigation we noticed that while using removeDelayedCalls(), id of that delayed call is not being removed from _objectIDs, therefore later after using remove() with the same delay call we get an error.

We believe instead of delete _objectIDs[tween]; there should be delete _objectIDs[delayedCall];

in function originally copied below:

    /** Removes all delayed and repeated calls with a certain callback. */
    public function removeDelayedCalls(callback:Function):void
    {
        if (callback == null) return;

        for (var i:int=_objects.length-1; i>=0; --i)
        {
            var delayedCall:DelayedCall = _objects[i] as DelayedCall;
            if (delayedCall && delayedCall.callback == callback)
            {
                delayedCall.removeEventListener(Event.REMOVE_FROM_JUGGLER, onRemove);
                _objects[i] = null;
                delete _objectIDs[tween];
            }
        }
    }

With Best Regards.

NN Team.

PrimaryFeather commented 7 years ago

Maaaaan, you're right! Damn copy-paste errors ... nothing good ever comes out of copying and pasting. 😜

Fixed right away. Thanks a lot for the heads-up, and greetings to Berlin!!