# Here is a Simple one I know it?

**URL:** <https://forum.kirupa.com/t/here-is-a-simple-one-i-know-it/30603>\
**Category:** Uncategorized\
**Created:** [September 11, 2003, 3:00am UTC](https://forum.kirupa.com/t/here-is-a-simple-one-i-know-it/30603 "2003-09-11T03:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dethroner](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@Dethroner](https://forum.kirupa.com/u/Dethroner)\
**Post date:** [September 11, 2003, 3:00am UTC](https://forum.kirupa.com/t/here-is-a-simple-one-i-know-it/30603/1 "2003-09-11T03:00:00Z")

</div>

On the following AS how would I load one jpg from the array with a button into a mc holder?

* * *

this.pathToPics = “images/”;  
// fill this array with your pics  
this.pArray = [“01.jpg”, “02.jpg”, “03.jpg”, “04.jpg”, “05.jpg”, “06.jpg”, “07.jpg”, “08.jpg”, “09.jpg”, “10.jpg”, “11.jpg”, “12.jpg”, “13.jpg”, “14.jpg”, “15.jpg”, “16.jpg”, “17.jpg”, “18.jpg”, “19.jpg”, “20.jpg”, “21.jpg”, “22.jpg”, “23.jpg”, “24.jpg”, “25.jpg”, “26.jpg”, “27.jpg”, “28.jpg”, “29.jpg”];  
this.fadeSpeed = 20;  
this.pIndex = 0;  
// MovieClip methods ----------------------------------  
// d=direction; should 1 or -1 but can be any number  
// loads an image automatically when you run animation  
loadMovie(this.pathToPics+this.pArray[0], “\_root.holder”);  
MovieClip.prototype.changeholder = function(d) {  
// make sure pIndex falls within pArray.length  
this.pIndex = (this.pIndex+d)%this.pArray.length;  
if (this.pIndex\<0) {  
this.pIndex += this.pArray.length;  
}  
this.onEnterFrame = fadeOut;  
};  
MovieClip.prototype.fadeOut = function() {  
if (this.holder.\_alpha\>this.fadeSpeed) {  
this.holder.\_alpha -= this.fadeSpeed;  
} else {  
this.loadholder();  
}  
};  
MovieClip.prototype.loadholder = function() {  
// specify the movieclip to load images into  
var p = \_root.holder;  
// ------------------------------------------  
p.\_alpha = 0;  
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);  
this.onEnterFrame = loadMeter;  
};  
MovieClip.prototype.loadMeter = function() {  
var i, l, t;  
l = this.holder.getBytesLoaded();  
t = this.holder.getBytesTotal();  
if (t\>0 && t == l) {  
this.onEnterFrame = fadeIn;  
} else {  
trace(l/t);  
}  
};  
MovieClip.prototype.fadeIn = function() {  
if (this.holder.\_alpha\<100-this.fadeSpeed) {  
this.holder.\_alpha += this.fadeSpeed;  
} else {  
this.holder.\_alpha = 100;  
this.onEnterFrame = null;  
}  
};  
// Actions -----------------------------------------  
// these aren’t necessary, just an example implementation  
this.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
this.changeholder(-1);  
} else if (Key.getCode() == Key.RIGHT) {  
this.changeholder(1);  
}  
};  
Key.addListener(this);
