Help this actionscript

hi there i am newbie here and this is my first time trying actionscript, i wanna ask i have this code bellow that calls an external image within its folders and its button based, i want to change it into autoplay onload without having its buttons, can anyone help me out? i really dont understand the script… all i wanna is auto load and auto play all the images from a folder… thx guys, here is the code bellow:

imgbtn1.onRelease = function() {
infoField._visible = true;
startLoading(“1.jpg”);
};
imgbtn2.onRelease = function() {
infoField._visible = true;
startLoading(“samsung.jpg”);
};
imgbtn3.onRelease = function() {
infoField._visible = true;
startLoading(“picture3.jpg”);
};
function startLoading(whichImage) {
loadMovie(whichImage, “imageLoader”);
_root.onEnterFrame = function() {
infoLoaded = imageLoader.getBytesLoaded();
infoTotal = imageLoader.getBytesTotal();
percentage = Math.floor(infoLoaded/infoTotal*100);
infoField.text = percentage+“%”;
if (percentage>=100) {
delete this.onEnterFrame;
infoField._visible = false;
}
};
}

:|:|:|:|

With your description i understand that you are looking for some kind of slide show application with autoload and auto play features. For autoloading you may sequentially load images one after the other and the end of the loadcomplete event of the first image make a call to load the next image.For autoplaying you may use a setinterval and call your loadImage function

how may i do that witout having to click, just play all the images by itself… help pls thx

Code for Auto Play

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 300;

var container:MovieClip = createEmptyMovieClip(“container”, getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

function loadImage(imgDetails):Void {

mcLoader.loadClip(“YourImage.jpg”, container);

trace("executeCallback intervalId: " + intervalId + " count: " + count);
if(count >= maxCount) {
clearInterval(intervalId);
}
count++;
}

intervalId = setInterval(this, “loadImage”, duration);

[LIST]
[]Use MovieClipLoader to load Images bcos u have init progress complete events
[
]In the body of the loadimage execute the Moviecliploader class’s loadClip method to load images.
[*]For auto loading call the loadImage function as the first and loading will happen automatically.
[/LIST]

how bout that there is more than one image, lets say i have 10pics and it will always be updated, will it be able to take all the pics and display it? thx for the help given :smiley:

If there are more images pls us a counter and load them in a sequence. If the images are often updated by the server use a getTimer() or a ? appended with the request that you make for loading images. This will at all times load only the latest image.

i have tried this :

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 300;

var container:MovieClip = createEmptyMovieClip(“container”, getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

function loadImage(imgDetails):Void {

mcLoader.loadClip(“YourImage.jpg”, container);

trace("executeCallback intervalId: " + intervalId + " count: " + count);
if(count >= maxCount) {
clearInterval(intervalId);
}
count++;
}

intervalId = setInterval(this, “loadImage”, duration);

and yes it can only load one image, i tried adding a counter but still i am really new to action script programming
dont know where to add the line, can u please help me out here? thx a lot mate :smiley:

i tried this code here :

onClipEvent (load) {
swfArray = new Array();

var ImageMainName = “top_”;
var ImageExtension = “.jpg”;
var ImageName = “”;

for (a=1; a<=20; a++) {
ImageName = ImageMainName+a+ImageExtension;
//trace(ImageName)
swfArray.push(ImageName);
}

i = swfArray.length;
k = Math.floor(Math.random()*i);

trace("— ARRAY —
Length: “+i+”
Random Array Index: “+k+”
Element: “+swfArray[k]+”
");
tesMc.loadMovie(swfArray[k]);

currentIndex = 0;
LoadImage();

function LoadImage() {
//trace("Array Index: “+currentIndex+” Image: "+swfArray[currentIndex]);
//currentIndex = Math.floor(Math.random()*i);
tesMc.loadMovie(swfArray[currentIndex]);
currentIndex++;
if (currentIndex>=i) currentIndex = 0;
}

var IntervalID = setInterval(LoadImage, 1000);
}

onClipEvent (unload) {
clearInterval(IntervalID);
}

still i cant get it to work, no image displayed here… so sad :frowning:

i tried this code here :

onClipEvent (load) {
swfArray = new Array();

var ImageMainName = “top_”;
var ImageExtension = “.jpg”;
var ImageName = “”;

for (a=1; a<=20; a++) {
ImageName = ImageMainName+a+ImageExtension;
//trace(ImageName)
swfArray.push(ImageName);
}

i = swfArray.length;
k = Math.floor(Math.random()*i);

trace("— ARRAY —
Length: “+i+”
Random Array Index: “+k+”
Element: “+swfArray[k]+”
");
tesMc.loadMovie(swfArray[k]);

currentIndex = 0;
LoadImage();

function LoadImage() {
//trace("Array Index: “+currentIndex+” Image: "+swfArray[currentIndex]);
//currentIndex = Math.floor(Math.random()*i);
tesMc.loadMovie(swfArray[currentIndex]);
currentIndex++;
if (currentIndex>=i) currentIndex = 0;
}

var IntervalID = setInterval(LoadImage, 1000);
}

onClipEvent (unload) {
clearInterval(IntervalID);
}

still i cant get it to work, no image displayed here… so sad :frowning:

hi flashdeva,

i manage to load external images, multiple image but now my question is how can set the location to a folder?

this is the modified code :

onClipEvent (load) {

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 2;
var duration:Number = 800;
swfArray = new Array();

var ImageMainName = “top_”;
var ImageExtension = “.jpg”;
var ImageName = “”;

for (a=1; a<=2; a++) { // Dynamically creates array of image names
ImageName = ImageMainName+a+ImageExtension;
//trace(ImageName)
swfArray.push(ImageName); //Adds the element to the end of array and increases the length by one
}

i = swfArray.length;
k = Math.floor(Math.random()*i);    // Returns a random number from 0 to 19

currentIndex = 0; // Array elements are zero based. So first image’s index=0

var container:MovieClip = createEmptyMovieClip(“container”, getNextHighestDepth());
var loaderImg:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

function loadImage(imgDetails):Void {

loaderImg.loadClip(swfArray[currentIndex], container);
currentIndex++;
if (currentIndex&gt;=i) currentIndex = 0; // "i" is the Arrays length

	//trace("executeCallback intervalId: " + intervalId + " count: " + count);

// if(count >= maxCount) {
// clearInterval(intervalId);
// }
count++;
}

intervalId = setInterval(this, “loadImage”, duration);

}

pls ignore the rest of my post, just help me answer this thx a lot mate :smiley: :smiley: :smiley:

[quote=superbogel;2358859]hi flashdeva,

i manage to load external images, multiple image but now my question is how can set the location to a folder?

this is the modified code :

pls ignore the rest of my post, just help me answer this thx a lot mate :smiley: :smiley: :D[/quote]

Keep the assets or pictures in the same path as your swf file is. That is the assets must be relative to your SWF. Consider the following scenario

[LIST]
[]Suppose if SlideShow.swf is the file that loads a jpeg called “picture1.jpg” which resides in a folder called “assests” then you would refer picture1.jpg from SlideShow.swf as follows.
[LIST]
[
]loadImage(“assets/picture1.jpg”)
[]Say you donot have a data folder then you can reference it like
[
]loadImage(“picture1.jpg”)
[/LIST]
[*]I hope this answers your question
[/LIST]