Be a Supporter!

[as2] reset movieclip?

  • 619 Views
  • 2 Replies
New Topic Respond to this Topic
Thrallec101
Thrallec101
  • Member since: May. 15, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
[as2] reset movieclip? 2012-11-09 15:55:46 Reply

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


...

Max-Vador
Max-Vador
  • Member since: Nov. 12, 2005
  • Offline.
Forum Stats
Member
Level 13
Animator
Response to [as2] reset movieclip? 2012-11-09 16:01:39 Reply

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());
milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to [as2] reset movieclip? 2012-11-09 16:31:26 Reply

@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.