A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: loading swfs w/ a numeric variable

  1. #1
    Junior Member
    Join Date
    Apr 2004
    Location
    georgetown, wa
    Posts
    12

    loading swfs w/ a numeric variable

    Flash_MX
    loading swfs using a numeric name variable?
    i am a bit of an AS hack but i have tried to pc. this together thru tutorials to no avail. can anyone chime in on the feasability of my goals here..or direct me to the tutorial for a more efficient method. thanks

    Objective: in english, i want to have the swf that holds my display container to load one of my 3 portfolio swf's..i have accomplished this using
    on (press) {
    container.loadMovie("print.swf");
    }
    AND THEN, once one of these are visible in the container i want to be able to script "next" and "previous" buttns to load my seqencially named image swfs forward or backwards ---into the container that is INSIDE the print.swf (P1.swf, P2.swf, P3.swf, etc.)

    So CAN I create a variable that determines which of the numbered swfs is currently loaded into the container and fetch the appropriate "next" or "previous" ?

    I have tried to review using variables Tutorials, but the integration with the loadMovie left me stupid. I am thinking that I need a call out to a frame where the variable sits but how the numeric reference is obtained is beyond me.

    is this realistic? any input is appreciated.
    bella3

  2. #2
    Junior Member
    Join Date
    May 2004
    Location
    Minnesoooodah
    Posts
    11
    I'm kind of a hack myself, but maybe this will help.
    I use this code to make sequential photo galleries:
    code:

    var index = 1;
    nextbtn.onRelease = function() {
    index++;
    if (index>20) {
    index = 1;
    } else if (index<1) {
    index = 20;
    }
    loadMovie("images/image"+index+".jpg", holder);
    };
    prevbtn.onRelease = function() {
    index--;
    if (index>20) {
    index = 1;
    } else if (index<1) {
    index = 20;
    }
    loadMovie("images/image"+index+".jpg", holder);
    };


    All this goes in frame 1. You have two buttons, nextbtn and prevbtn, and an empty movie clip named holder. The variable called index is what calls each file.

    Basically, the nextbtn button increases the variable index by 1, and then updates which picture is loaded based on that number. The prevbtn decreases index by 1 and does the same thing.

    So at the start, index is 1, and image1.jpg is loaded. When you click next, index changes to 2, so image2.jpg is loaded. (in your case you'd be loading swf's instead of jpg's, but it should work the same.) The if and else statements are to make it loop back through to the start/finish, otherwise it would just keep counting. The way I have it it's set up for 20 items; just change 20 to 3 and you'll loop thru the same 3 items.

    I'm terrible at explaining this stuff, but I hope I helped a little.
    --Mark.

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Location
    georgetown, wa
    Posts
    12

    INDIVIDUAL butn script vs variable script--different?

    MarkBT it has taken me a while to return to this task--but now I am confused--if above script lives in frame 1--how am I assigning call action to the butns themselves?
    Isn;t the concept that the whole variable code sits around waiting to be referenced but it isn't the main action actor?
    my obvioulsy i am confused--

    anyone?

    bunny3

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