A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: single button w/ multi- action

  1. #1
    Dear Flash Comrades,
    I have a single button in my main.swf, which needs to load a different extenal .swf, each time it is clicked.

    I have no idea what scripting is appropriate for this button. Does any one have any suggestions?


    thanks ,
    -superintendent


  2. #2
    try to put the name of the swf in a variable. Then use the loadmovie function with the variable. This way you change the value of the variable to load different movies.

    If that does not worf you can use if statements:

    if (variable==1){
    load first movie
    }
    if (variable==2){
    load second movie
    }

    And so on.

    Good luck

  3. #3
    Thanks very much for the suggestions. I'm a bit of a novice with variables-I've attempted the following scripts, but they are not working... any hints as to how to fix them?

    This script is in the first keyframe of the main timleine:

    loadMovie ("01.swf", "target");
    movie = "01";
    movie = "02";
    movie = "03


    This is the script for the Foward Button:

    on (release) {
    movie = "01";
    loadMovie ("02.swf", "target");
    movie = "02";
    loadMovie ("03.swf", "target");
    }

    any suggestions would be great!
    thanks,
    superintendent

    [Edited by superintendent on 08-31-2001 at 09:26 AM]

  4. #4
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    you are instansiating the same variable more than once in the same bit of code- none of these assignments will have any real effect apart from maybe the last one.

    Try using this code.

    1. instansiate the starting movie number somewhere in the root (this only gets done once at the start):
    movie_num = 0;


    2. make a button, also in the root:

    on (release) {
    loadMovie (movie_num + ".swf", movie_num);
    movie_num++;
    }


    3. name your external movies:
    0.swf, 1.swf,,, ,,,n.swf

    That should do it.

    You can also add in an if statement to the button to check how many movies you have got and cycle between them all.

    on (release) {
    loadMovie (movie_num + ".swf", movie_num);
    // i.e. for 12 swf files
    if (movie_num < 12) {
    movie_num++;
    } else {
    movie_num = 0;
    }
    }

    have fun,

    -L-
    [Edited by Lexicon on 08-31-2001 at 10:01 AM]

  5. #5


    Thanks Lexicon!

    Just one more question for you.
    I cannot get the back button to work correctly.
    would it be similiar to the foward button script?

    thanks,
    Superintendent

  6. #6
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    this would be a backward button

    Code:
    on (release) { 
    loadMovie (movie_num + ".swf", movie_num); 
    // i.e. for 12 swf files 
    if (movie_num > 0) { 
    movie_num--; 
    } else { 
    movie_num = 12; 
    } 
    }
    Mind you - if you are moving the counter in both directions it would probably be best to move the loadMovie lines for both buttons below the if statement, so that the counter changes before the swf is loaded.

    Code:
    //forward
    on (release) { 
    if (movie_num < 12) { 
    movie_num++; 
    } else { 
    movie_num = 0; 
    } 
    loadMovie (movie_num + ".swf", movie_num); 
    } 
    
    //backward
    on (release) { 
    if (movie_num > 0) { 
    movie_num--; 
    } else { 
    movie_num = 12; 
    } 
    loadMovie (movie_num + ".swf", movie_num); 
    }

    -L-

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