From 2d00a1ffc9d52a55dfc48acff390de0ccb2fd3b6 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sat, 24 Aug 2013 17:14:02 +0200 Subject: [PATCH] removeBehaviour no longer loops forever. also renamed to be consistent (u removed) deprecated old function --- src/Foundation/Actor.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index a60ac270..cda4acce 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -1461,15 +1461,26 @@ CAAT.Module({ * If the Behavior is not present at the actor behavior collection nothing happends. * * @param behavior {CAAT.Behavior.BaseBehavior} + * @deprecated */ removeBehaviour:function (behavior) { + this.removeBehavior(behavior); + }, + /** + * Remove a Behavior from the Actor. + * If the Behavior is not present at the actor behavior collection nothing happends. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + */ + removeBehavior:function (behavior) { var c = this.behaviorList; var n = c.length - 1; - while (n) { + while (n >= 0) { if (c[n] === behavior) { c.splice(n, 1); return this; } + n = n - 1; } return this; },