# Completly Restarting a flash movie

**URL:** <https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160>\
**Category:** programming\
**Created:** [June 23, 2008, 5:10pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160 "2008-06-23T17:10:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew2110](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@andrew2110](https://forum.kirupa.com/u/andrew2110)\
**Post date:** [June 23, 2008, 5:10pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/1 "2008-06-23T17:10:43Z")

</div>

Hi Guys,

I’m trying to figure out a way to completely restart my flash movie once for example the game has finished and the user wants to restart it. The issue is that there’s lots of dynamically generated variables and arrays and such and I’m pretty sure I have a few memory leaks inside the game as well. The easiest solution I can think of is just forcing the browser to refresh when the user clicks the replay button? Unless theres a better way of doing it?

I know the best way to do this is to free up all the variables and restart it all properly but I’ve been trying that for a few days and have now lost my patience with it.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 23, 2008, 6:41pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/2 "2008-06-23T18:41:13Z")

</div>

erm set the variables to 0

and the arrays to =[]

---

<div class="post-metadata">

**Author:** ![andrew2110](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@andrew2110](https://forum.kirupa.com/u/andrew2110)\
**Post date:** [June 23, 2008, 8:36pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/3 "2008-06-23T20:36:33Z")

</div>

Yea I thought I was just being lazy with this. Just been working for a long while now on fixing memory leaks (just moved from AS2 to AS3) and while its a lot better than it was, it’s still not perfect. I guess going through all this and making sure I have a handle on everything and free everything up will hopefully make it clear to be where I’ve messed up to allow memory leaks…

Thanks for the replies guys

---

<div class="post-metadata">

**Author:** ![Gathan](https://avatars.discourse-cdn.com/v4/letter/g/df705f/32.png) [@Gathan](https://forum.kirupa.com/u/Gathan)\
**Post date:** [June 23, 2008, 11:18pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/4 "2008-06-23T23:18:40Z")

</div>

You must make sure that all references to objects are removed, listeners are removed-might want to use weak references with listeners so you don’t have to worry about removing them, anything else that could keep a object alive, etc.  
It might seem like a pain right now, but after your used to doing it for a while it becomes routine.

---

<div class="post-metadata">

**Author:** ![tapioca](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@tapioca](https://forum.kirupa.com/u/tapioca)\
**Post date:** [June 24, 2008, 3:24pm UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/5 "2008-06-24T15:24:54Z")

</div>

loadMovieNum(“yourswf.swf”, 0);

MWAHAHAHAHA

---

<div class="post-metadata">

**Author:** ![tapioca](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@tapioca](https://forum.kirupa.com/u/tapioca)\
**Post date:** [June 25, 2008, 5:06am UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/6 "2008-06-25T05:06:21Z")

</div>

yeah, idk if it’s a good idea to use that or not… but it does technically work.

supposedly it was deprecated in flash 4 and doesn’t exist in as3.0

---

<div class="post-metadata">

**Author:** ![andrew2110](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@andrew2110](https://forum.kirupa.com/u/andrew2110)\
**Post date:** [June 25, 2008, 7:30am UTC](https://forum.kirupa.com/t/completly-restarting-a-flash-movie/264160/7 "2008-06-25T07:30:14Z")

</div>

Thanks for the replies guys,

I ended up going the wrong way round (but I suppose the proper way of doing things). I put destructors in all of my object which did removeChild()'s on all the movie clips it owned and free’d all the variables the objects owned and now its nearly working.Thanks for all of your help.
