Permalink
Browse files

added a destroy method to IAction implementations for cleanup with IT…

…riggerComponents are removed from an entity.
  • Loading branch information...
1 parent e66f2e8 commit 3dd067c7dd1f2fe20cd6487a7b349d4317a95f1c @hybridmindset committed Apr 4, 2011
@@ -30,6 +30,13 @@ package com.flexgangsta.pbtriggers
//Remove Event Handlers
this.owner.eventDispatcher.addEventListener(eventType,targetEventHandler);
+
+ var len : int = actions.length;
+ for(var i : int = 0; i < len; i++)
+ {
+ actions[i].destroy();
+ }
+ _lastReturn = null;
}
//______________________________________
@@ -75,7 +82,6 @@ package com.flexgangsta.pbtriggers
_exit=false;
return;
}
-
_lastReturn = action.execute();
}
}
@@ -60,6 +60,14 @@ package com.flexgangsta.pbtriggers.actions
return event;
}
+ public function destroy():void
+ {
+ for (var key:String in properties)
+ {
+ delete properties[key];
+ }
+ _owner = null;
+ }
//______________________________________
// Private Properties
//______________________________________
@@ -21,13 +21,17 @@ package com.flexgangsta.pbtriggers.actions
*/
function execute():*;
+ /**
+ * Destorys the current action and performs any cleanup
+ */
+ function destroy():void;
+
/**
*
* @param value A reference to the trigger that is hosting
* the action.
*
*/
function set owner(value:ITriggerComponent):void;
-
}
}
@@ -68,6 +68,16 @@ package com.flexgangsta.pbtriggers.actions
}
}
+ public function destroy():void
+ {
+ var len : int = args.length;
+ for(var i : int = 0; i < len; i++)
+ {
+ args.pop();
+ }
+ methodReference = null;
+ _owner = null;
+ }
//______________________________________
// Private Properties
//______________________________________
@@ -23,7 +23,7 @@ package com.flexgangsta.pbtriggers.actions
{
_owner=value;
}
-
+
//______________________________________
// Public Methods
//______________________________________
@@ -56,6 +56,12 @@ package com.flexgangsta.pbtriggers.actions
return _owner.owner.getProperty(property);
}
+ public function destroy():void
+ {
+ source = null;
+ property = null;
+ _owner = null;
+ }
//______________________________________
// Private Properties
//______________________________________

0 comments on commit 3dd067c

Please sign in to comment.