Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsCan you reset a movieclip and all of its functions, i'm making an object pool so i'm reusing the same ship/mc in my game and there are alot of variables on the ships onEnterFrame function so i just want to essentialy reload the movieclip, is this possible? and thanks in advance
...
At 11/9/12 03:55 PM, Thrallec101 wrote: Can you reset a movieclip and all of its functions, i'm making an object pool so i'm reusing the same ship/mc in my game and there are alot of variables on the ships onEnterFrame function so i just want to essentialy reload the movieclip, is this possible? and thanks in advance
removeMovieClip();
_root.attachMovie(mc, newMC, _root.getNextHighestDepth()); @thrallec:
Resetting something would be the same as setting it in the first place.
Do the initializing in one function that you can call again later on.
If you do object pooling for performance, you should consider other more common ways to improve it first:
- do not add an onEnterFrame function to every object
- As3, especially because it enables you to remove and re-add a DisplayObject, which you can't in As2
At 11/9/12 04:01 PM, Max-Vador wrote: removeMovieClip();
_root.attachMovie(mc, newMC, _root.getNextHighestDepth());
That does not reset the existing object but creates a new one instead, which is not how object pooling works.