all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

parsing??


parsing?? Hengy
10/29/2006 9:36:40 PM
flash actionscript:
ok. I have a variable - imgname = 1; i want to add 1 to it (so it equals 2). is
that variable a string, or an integer? and how do i convert it to an integer?

here is some code i have for an image viewer i am making:
frame 1:
imgpath = "Photos/";
imgname = 3;
extension = ".JPG";
alpha = 4;

frame 2:
imgloader.contentPath = imgpath + imgname + extension;

imgloader._alpha = alpha;

frame 3:
if (imgloader._alpha != 100) {
alpha = alpha + 2;
}

nextb.OnRelease = function() {
imgname = imgname + 1;
}

gotoAndPlay(2);

I want to, whenever you press next (nextb), for it to load the next picture,
named 2.JPG.
Can anyone pleae help?

Thanks, Hengy
Re: parsing?? kglad
10/30/2006 12:00:00 AM
Re: parsing?? kglad
10/30/2006 1:45:54 AM
try:



nextb.OnRelease = function() {
if(imgname<maxImages){ // <-- you should define maxImages
imgloader.contentPath = imgpath + (imgname+1) + extension; // <--
paranethesis needed to prevent string addition
}
}


// and remove that imgloader.contentPath statement that's attached to frame 2.
Re: parsing?? Hengy
10/30/2006 2:08:33 AM
Thanks kglad , but I experimanted a little, and now I got some new code, which
I still have some trouble with...

Frame 1:
imgloader.contentPath = "Photos/1.JPG";

numimg = 15;

var imgpath = "Photos/";
var extension = ".JPG";
var alpha = 0;

varx = 0;
var myArray = new Array();
var i = 0;
do {
MyArray[i] = imgpath+i+extension;
i++;
}
while (i <= numimg);

Frame 2:
imgloader._alpha = alpha;

Frame 3:
if (imgloader._alpha != 100) {
alpha = alpha + 2.5;
}

nextb.onRelease = function() {
myProgressBar.mode = "manual";
myProgressBar.setProgress(0, 100);
varx = varx + 1;
myProgressBar.mode = "polled";
if (varx > numimg) {
varx = varx - 1;
}
imgloader.contentPath = MyArray[varx];
alpha = 0;
gotoAndPlay(2);
}

prevb.onRelease = function() {
myProgressBar.mode = "manual";
myProgressBar.setProgress(0, 100);
varx = varx - 1;
myProgressBar.mode = "polled";
if (varx < 0) {
varx = varx + 1;
}
imgloader.contentPath = MyArray[varx];
alpha = 0;
gotoAndPlay(2);
}

gotoAndPlay(2);

This is now what i have got. I am having trouble with the Array, I think. When
I click next, it responds, but it only clears the first picture and resets the
preloader back to 0. It doesn't load the new picture. This is also the case
with the previous button.
Any ideas?
Thanks, Hengy
Re: parsing?? kglad
10/30/2006 2:17:07 AM
is your scrollPane on all three frames?

is 1.JPG loading?

(your test for first and last image isn't going to work the way you want.)

and use the attach code option. among other things it prevents this forum
from mangling your code, especially when you use [ i ].
Re: parsing?? Hengy
10/30/2006 2:55:34 AM
Sorry about the code.
I am not sure what you mean by scrollPane...
And yes, 1.JPG does load.
Re: parsing?? Hengy
10/30/2006 4:16:47 PM
ok. I am currently at school... I will post the link ASAP.
Re: parsing?? Hengy
10/30/2006 9:23:31 PM
Re: parsing?? kglad
10/31/2006 12:00:00 AM
Re: parsing?? Hengy
10/31/2006 4:03:28 PM
:frown; Sorry. I wonder why that happened... I will post it again when I get home.

Re: parsing?? Hengy
10/31/2006 8:47:29 PM
ok. Here is the file: http://www.geocities.com/matthengy/MediaVeiwer.zip And, if that one doesn't work... http://www.geocities.com/matthengy/MediaVeiwer.fla

Thanks for all your help!
Re: parsing?? kglad
11/1/2006 1:35:21 AM
Re: parsing?? Hengy
11/1/2006 10:55:13 PM
That worked! I don't know how I missed that... I guess the lesson here is to be more careful. Thanks kglad!
Re: parsing?? kglad
11/1/2006 11:17:51 PM
you're welcome.

AddThis Social Bookmark Button