A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: looping the loadmovie

  1. #1
    Hi there,
    is it possible to load external swf movies by using a loop?

    This is what i want to do:
    I have made a photo album with flash and I want to be able to add new albums to the main one without having to alter the main movie.
    So I want the main movie to "search" for new album components and display them if they are found (eg 1.swf, 2.swf...etc).

    I was thinking that if i created some sort of load movie loop i would be able to overcome this problem, unfortunatly i'm quite a sad actionscripter and i have no idea how to do this.

    cheers

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    How about this:

    on(press) {
    i++;
    loadMovie("movie0" + i + ".swf")
    }

    Go to the previous one by:

    on(press) {
    i--;
    loadMovie("movie0" + i + ".swf")
    }

    And, yes, you could do it with a loop. You could set up an mc that contains the number of frames you wanted to process before the above core code is activated at the end.

  3. #3

    thanx kenny

    Thanx man, i'll give it a go.

  4. #4

    problems, problems....

    ok, I want the movie to scan for new swf's at the start of the movie (automatically-without button push).
    I tried this script (don't laugh!!!!)

    i = "1";
    if (i<10) {
    i++;
    loadMovie("movie0" + i + ".swf",1+i)
    } else {
    stop();

    But it doesn't seem to work...

    Any ideas?

    Thanx in advance!!!!

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    Where do you have this code?

    Try:

    i = 1;
    if (i<10) {
    i++;
    loadMovie("movie0" + i + ".swf",1+i)
    trace("I: " + i);
    } else {
    stop();

    Remove the quotes around the one. Trace i so you can see what's happening.

  6. #6

    hey again

    Originally posted by Kennyb
    Where do you have this code?

    Try:

    i = 1;
    if (i<10) {
    i++;
    loadMovie("movie0" + i + ".swf",1+i)
    trace("I: " + i);
    } else {
    stop();

    Remove the quotes around the one. Trace i so you can see what's happening.
    I've got it at the first frame of the main timeline (is that the right place?)

    I put the trace in and i only get the output "i:2" somehow i don't think it's looping...

    thanx again

  7. #7
    i removed the quotes, but that gives me an error message...

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449

    To make a loop use "while" or "for":

    Code:
    i = 1; 
    while (i<10) { 
    loadMovie("movie0" + i + ".swf",1+i); 
    i++; 
    }

  9. #9
    hi again,

    ok I tried cancerinform's solution, but alas it still doesn't work, for some reason it won't pick up the variable.
    eg:


    loadMovie("movie"+"1"+".swf", 1); (this works)


    x = "1";(or x=1)
    loadMovie("movie"+x+".swf", 1); (this doesn't)

    Any ideas??

    cheers

  10. #10
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    If you want, I'll look at your fla. Please post it some place where it can be downloaded. If it is less than 1MB, you can email it to me at: aspirin99@hotmail.com. Please remind me in the email exactly what you are try to do and where the trouble is.

  11. #11
    Senior Member
    Join Date
    Apr 2002
    Posts
    682
    This should work.

    i = 1;
    while (i<=5) {
    createEmptyMovieClip (mc+i, i);
    loadMovie("movie" + i + ".swf",mc+i);
    i++;
    }

    One more thing, the above code will check for files 1 to 6.

  12. #12
    Thanks KennyB, I've also found out that this works as well:

    i = 1;
    while (i<10) {
    loadMovieNum("movie" + i + ".swf",1+i);
    i++;
    }

    Alls well that ends well!!!!!!!!!!!!!!!!

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