Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : reading images


aesthetix
10/9/2005 10:43:24 PM
hi guys,

i have a movie clip name 'gall', this movie clip is used to load images off
from a web directory 'images', i have 2 movieclips which for navigation
(previous and next), the problem i'm facing now is that i'm not sure how i
should actually load the images from this web directory and use the 2
movieclilps for navigation to navigate thru this web directory of images.. help
anyone?

thanks
kglad
10/9/2005 11:08:23 PM
if you know the names of the images list them in an array and script your next
and previous buttons control the array's index:

imageA=[your images listed here];
ind=-1;
nextBtn.onPress=function(){
ind++;
// you might reset ind when it equals imageA.length
targetMC.loadMovie(imageA[ind]);
}
prevBtn.onPress=function(){
ind--;
//you might reset if less than zero.
targetMC.loadMovie(imageA[ind]);
}
aesthetix
10/9/2005 11:15:20 PM
aesthetix
10/9/2005 11:40:25 PM
help anyone?
Stasa
10/9/2005 11:54:38 PM
.... you can name your pictures 1.jpg, 2.jpg, 3.jpg ...

and add code below to first frame of your movie. You must have tvo movies
named
'left' and 'right' as the movie clip for where you will load pics named
'movie'...
or you can rename variables in script. In code is string with value
'numOfLastImage+1' you replace this with last number of your image+1as the
line of code below but withouth 1... The pictures need to be placed in same
directory as the movie. If they ar not in same directory, you need to specify a
path to that directory in 'movie.loadMovie()' example

movie.loadMovie( "pics/"+i+".jpg") .Just replace 'pics' with your path

I hope this will help


//Script for slide show
i = 0;
right.onRelease = function(){
i++;
if(i == numOfLastImage+1){
i = numOfLastImage;}
movie.loadMovie(i+".jpg");}
left.onRelease = function(){
i--;
if(i == 0){
i = 1;}
movie.loadMovie(i+".jpg");}
aesthetix
10/10/2005 12:00:00 AM
aesthetix
10/10/2005 12:00:00 AM
i tried it and it doesn't work, here's my code:

i = 0;
nxt.onRelease = function(){
i++;
if(i == numOfLastImage+1){
i = 1;}
gall.loadMovie( "works/"+i+".jpg");
}
prev.onRelease = function(){
i--;
if(i == 0){
i = numOfLastImage;}
gall.loadMovie("works/"+i+".jpg");
}
aesthetix
10/10/2005 12:20:42 AM
Stasa
10/10/2005 12:28:59 AM
You have to remake it in Photoshop or some other program to that size (easyest
way) or to make scrip to resize pics to that size, what is not so easy for
newby,
because of inheritance scalled movie in what you load pics.
aesthetix
10/10/2005 12:35:35 AM
aesthetix
10/10/2005 12:36:30 AM
Stasa
10/10/2005 12:37:50 AM
Stasa
10/10/2005 12:38:05 AM
Stasa
10/10/2005 8:34:14 AM
You have to replace code to this

//Script for slide show
i = 0;
right.onRelease = function(){
i++;
if(i == numOfLastImage+1){
i = 1;}
movie.loadMovie(i+".jpg");}
left.onRelease = function(){
i--;
if(i == 0){
i = numOfLastImage;}
movie.loadMovie(i+".jpg");}

compare this scrip with script posted before and you see a difference.
Stasa
10/10/2005 7:32:49 PM
.... logically it won't work, because you dont replace 'numOfLastImage' with
number of your last image. Code below works with 4 pictures. If you have more
or less pics, than you replace number 4 with number of your last image.
Srory ... my mistake I did not tell you that you have to replace that in code.

i = 0;
nxt.onRelease = function(){
i++;
if(i == 4+1){
i = 1;}
gall.loadMovie("works/"+i+".jpg");
}
prev.onRelease = function(){
i--;
if(i == 0){
i = 4;}
gall.loadMovie("works/"+i+".jpg");
}
aesthetix
10/10/2005 7:44:39 PM
nah it's fine, not your fault, i just misinterpreted it... anyways, is there a way that i last image to be the first? and when i click nxt.button it goes descending like 101,100,99,98.... etc.?
Stasa
10/10/2005 7:58:44 PM
set first 'i' to 100, and change third line of code to 'i--'; it will descend.
AddThis Social Bookmark Button