Results 1 to 10 of 10

Thread: Completly Restarting a flash movie

  1. #1

    Completly Restarting a flash movie

    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.

  2. #2
    1,532
    posts
    I make half sense
    erm set the variables to 0

    and the arrays to =[]
    Click my sig.

  3. #3
    Quote Originally Posted by andrew2110 View Post
    The issue is that there's lots of dynamically generated variables and arrays
    Well, you've got to keep a handle on this stuff as it's being populated!
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  4. #4
    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

  5. #5
    213
    posts
    Registered User
    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.

  6. #6
    loadMovieNum("yourswf.swf", 0);

    MWAHAHAHAHA

  7. #7
    Quote Originally Posted by tapioca View Post
    loadMovieNum("yourswf.swf", 0);

    MWAHAHAHAHA
    You've still got to keep a handle on stuff as it's being created!

    But yes, this will work.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  8. #8
    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
    Last edited by tapioca; June 25th, 2008 at 01:12 AM.

  9. #9
    Quote Originally Posted by tapioca View Post
    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
    I mean, just put all your stuff in a "container" movieclip...it's the same thing, really.
    you = function(){
    setEnabled( true );
    live();
    setEnabled( false );
    }

  10. #10
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012