A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: A rather singular problem(the best kind)

  1. #1
    Junior Member
    Join Date
    Jan 2004
    Posts
    7

    A rather singular problem(the best kind)

    The title says it all. You see, in my battle sim, I need a preloader if I don't want my soldiers moving like they're concussed, if you catch my drift.

    However, no matter what tutorial I find for preloaders, none of them shows how to make a preloader which will wait until each of my soldiers (individual movie clips) have loaded, and then and only then play the frame containing the battle sequence. I've tried a variety and none of them will work. I know singular problems like this are a bit tricky, but still I'd appreciate it if you could help, as I'm sure you already know...
    "The world is quiet here."

  2. #2
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173

    Preloading

    An off-the-cuff response--- have the onLoad() event handler of each movie clip send a message to a preloader clip, which either counts the messages, or checks individual names against a list.

    E.g., each movie clip to be loaded has on its timeline the code
    Code:
    onLoad = function() {
            _root.gatekeeper.checkin(this.name);
    }
    and gatekeeper has a method

    Code:
    numPresent = 0;
    numExpected = 25;
    
    checkin = function(name) {
            numPresent++;
            if(numPresent == numExpected) {
                  _root.gotoAndPlay(2);
            }
    // or check the individual names against a roster

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Movie clips (if they are movie clips and not external.swfs loaded in movie clips), all should preload, without any problems, within the main movie's preloader.
    Unless you give us more info on the code of preloaders you have tried, or attach the one you're presently trying, then I guess your soldiers will continue "moving like they're concussed"!

  4. #4
    Junior Member
    Join Date
    Jan 2004
    Posts
    7
    Nope, 's still not working. I think it may have something to do with the fact that the lines of code to duplicate the movieclip are on the frame after the preloader... Or in the fact that it's duplicated at all. If you duplicate a movie clip, will it retain its actionscript?

    Edit: I've tried three different ones, but I don't recall which ones they were. Also, I deleted the code when I put in mkantor's suggestion for a preloader.
    Last edited by vrover; 01-22-2004 at 10:32 PM.
    "The world is quiet here."

  5. #5
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    I think it may have something to do with the fact that the lines of code to duplicate the movieclip are on the frame after the preloader
    If the movie clip loads once up front, then, as oldnewbie says, teh preloader will take care of it. Subsequent duplication shouldn't take long. On the other hand, if the movie clip is not present on frame 1, then it won't be counted as part of the total bytes, and the preloader won't wait for it.

    Actionscript is of two kinds. Code in the timeline of a movie clip will be duplicated when the movie clip is duplicated. Code attached to an instance will not be duplicated.

  6. #6
    Junior Member
    Join Date
    Jan 2004
    Posts
    7
    Originally posted by mkantor
    If the movie clip loads once up front, then, as oldnewbie says, teh preloader will take care of it. Subsequent duplication shouldn't take long. On the other hand, if the movie clip is not present on frame 1, then it won't be counted as part of the total bytes, and the preloader won't wait for it.
    Does this mean I must put one instance of the movie clip in a frame before the preloader? Or am I misreading you? If I have to, it won't be a problem.. I could just include some code to delete it on load.


    Actionscript is of two kinds. Code in the timeline of a movie clip will be duplicated when the movie clip is duplicated. Code attached to an instance will not be duplicated.
    That's strange, because the code I attached to the first instance to create a random location showed up in the duplicates perfectly.
    "The world is quiet here."

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    To duplicate a movie clip it has to be on or off-stage already, right?

  8. #8
    ActionScript Insomniac
    Join Date
    Jan 2003
    Location
    43d03.21'N, 89d23.65'W
    Posts
    1,173
    Does this mean I must put one instance of the movie clip in a frame before the preloader?
    The same frame as the preloader should be sufficient.

    Sorry, I realize now that in my second answer, which seems to be wrong, I was thinking about attachMovie, not duplicateMovieClip, which I do not use.

  9. #9
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    If linkage is set to export on the first frame on a movie clip, you don't need to put an instance on stage for it to load within the main movie's preloader.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center