|
-
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!
-
Senior Member
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
-
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");
};
-
Thanks Eraser-ad and Insane-Tomato
You guys really helped me a lot!
-
Senior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|