+ Reply to Thread
Results 1 to 5 of 5

Thread: Actionscript: avoid loading the same file twice

  1. #1
    thotalg is offline x10Hosting Member thotalg is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    2

    Actionscript: avoid loading the same file twice

    Greetings, i hope this is the right place for this question.


    i'm working on a flash project that Loades lots of movieClips onto the main movie depending on the user choise.

    Right now i'm working under a Mac and use Safari for most of my tests and i hafond that when ever my flash needs to load again a previusly loaded clip instead of just grab the already loaded one loaded another instance of the file, this turns out into a problem 'cos after a minute of user experience the "activity list" tells me i have about 158 files loaded when i'm actually using only around 20.

    I supose it has to do with my method to load them (the clasic one on action script)

    onClick {
    loadMovieClip('clipURL', 'targetClip');
    }

    if it was just matter of keep the list small, well, no problem... but it keeps loading and loading the memory of the sistem and, after a few trial i made on windows and mac, the page turns to consume so much resouces of the sistem that makes it unstable, some times it even crashes the sistem (specially when u keep clicking and loading the same clip again and again).

    i've read that on php exist a couple of functions called "include_once" and "require_once" that "loads" a page or script on the "stage" only once, and if is required to be loaded again it takes the same that was included before, php.netexplains that is to avoid overloading the systems, to reduce bandwidth use and avoid renaming functions or re-declaring important stuff(not sure bout what "stuff")

    so, my question would be, is there something like php's include_once on actionScript?

    if not, how can i avoid expend my bandwidth loading again and agoin a new instance of the same file?

    take NOTICE that i'm working on a 100% dynamic flash site, most of the content is loaded on runtime and very few elements are static as the flash plays.

    (sorry about the "part naming" i use, using so much flash changes the way one name things)

    Thanks a lot in advance

  2. #2
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Actionscript: avoid loading the same file twice

    you could cache the movies, or preload them
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  3. #3
    thotalg is offline x10Hosting Member thotalg is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    2

    Re: Actionscript: avoid loading the same file twice

    Quote Originally Posted by xav0989 View Post
    you could cache the movies, or preload them
    PRELOAD: tryed already, seems the error is on the way i call the loading cos, even if i preload the clips the activity list on safari tells me that it keeps loading the same movie clip once and again spending bandwidth and memory.

    same aplies to the caheing the clips

  4. #4
    VPmase's Avatar
    VPmase is offline x10 Elder VPmase is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Dixon, IL, USA
    Posts
    914

    Re: Actionscript: avoid loading the same file twice

    If I'm right, the loadMovieClip returns a true or false value.
    So just make a var on the layer (we'll call it loadedmc:Boolean = new Boolean; loadedmc = false; //make it and set it to false) and add this to the code

    Code:
    onClick {
    if(!_root.loadedmc){
    _root.loadedmc = loadMovieClip('clipURL', 'targetClip');
    }
    }

  5. #5
    johnbeeby is offline x10Hosting Member johnbeeby is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    8

    Re: Actionscript: avoid loading the same file twice

    on (release) {
    loadMovieClip('clipURL', 'targetClip');
    unloadMovieClip('URL', '_target');
    }

    Its best to un-include where possible. Just list all the clips you want to unload. If they are cached they will load immediately next time they are called.

    Unless I totally missed the point of this, I think its a simple means of un-including files or else they will play and play and play and can be loaded on top of each other over and over without specific direction of unloadMovieClip.
    johnbeeby.co.cc

+ Reply to Thread

Similar Threads

  1. It works! ...
    By bpakidz in forum Programming Help
    Replies: 4
    Last Post: 09-07-2008, 11:12 PM
  2. Internal Serve Error
    By xaakx in forum Free Hosting
    Replies: 6
    Last Post: 02-03-2008, 08:02 AM
  3. help!!
    By retro-bliss in forum Free Hosting
    Replies: 25
    Last Post: 12-07-2007, 01:12 PM
  4. Replies: 8
    Last Post: 12-03-2007, 04:12 PM
  5. php version
    By loveispoison in forum Free Hosting
    Replies: 10
    Last Post: 11-21-2007, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers