A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Please help, question on actionscript

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Posts
    11

    Please help, question on actionscript

    I got to load a list of JPGs in a swf, for the code I'm currently using:

    MovieClip1.loadMovie("S0001.JPG");
    MovieClip1.loadMovie("S0002.JPG");
    MovieClip1.loadMovie("S0003.JPG");

    But in the real suitation, I need is to load JPGs in MovieClip1, and by pressing Button "Next","Next x2", "Previous" and "Previous x2", it will have an action.

    i.e.
    MovieClip1 -> loads S0001.JPG as default
    After clicking "Next"
    MovieClip1 -> loads S0002.JPG
    After clicking "Next x2"
    MovieClip1 -> loads S0004.JPG
    After clicking "Previous"
    MovieClip1 -> loads S0003.JPG
    After clicking "Previous x2"
    MovieClip1 -> loads S0001.JPG
    and so on

    How can I make the variable (S0001.JPG) split into "S"+"####"+".JPG" which the "####" can be a bigger or smaller number by a function in the button?

    Please note that the list of JPGs must be in this format of naming, "S"+"####"+".JPG"

    Please help!

  2. #2
    Senior Member eraser_ad's Avatar
    Join Date
    Apr 2004
    Posts
    189
    try this

    code:

    var nNumber:Number = 1;
    nextButton.onRelease = function() {
    nNumber++;
    this.MovieClip1.loadMovie("S"+nNumber+".jpg");
    };
    prevButton.onRelease = function() {
    nNumber--;
    this.MovieClip1.loadMovie("S"+nNumber+".jpg");
    };

    some smart citation is coming here soon

  3. #3
    Junior Member
    Join Date
    Jul 2004
    Location
    Malaysia
    Posts
    8
    Originally posted by eraser_ad
    try this

    code:

    var nNumber:Number = 1;
    nextButton.onRelease = function() {
    nNumber++;
    this.MovieClip1.loadMovie("S"+nNumber+".jpg");
    };
    prevButton.onRelease = function() {
    nNumber--;
    this.MovieClip1.loadMovie("S"+nNumber+".jpg");
    };


    if you follow eraser_ad's coding, you must change your jpeg file name to S1.jpg, S2.jpg...etc. If you don't want to change you can use like this:


    code:

    var nNumber:Number = 1;
    var fileNum:String;
    nextButton.onRelease = function() {
    nNumber++;
    fileNum = "0000"+sNumber;
    fileNum = fileNum.substr(fileNum.length-4, fileNum.length)
    this.MovieClip1.loadMovie("S"+fileNum+".jpg");
    };


  4. #4
    Junior Member
    Join Date
    Feb 2003
    Posts
    11
    Thanks Eraser-ad and Insane-Tomato
    You guys really helped me a lot!

  5. #5
    Senior Member eraser_ad's Avatar
    Join Date
    Apr 2004
    Posts
    189
    thx Insane Tomato
    I actually just learned something new from here too. Thanks
    some smart citation is coming here soon

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