# Attaching jpegs

**URL:** <https://forum.kirupa.com/t/attaching-jpegs/170786>\
**Category:** Uncategorized\
**Created:** [November 29, 2005, 4:14pm UTC](https://forum.kirupa.com/t/attaching-jpegs/170786 "2005-11-29T16:14:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sixtyminuteman](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@sixtyminuteman](https://forum.kirupa.com/u/sixtyminuteman)\
**Post date:** [November 29, 2005, 4:14pm UTC](https://forum.kirupa.com/t/attaching-jpegs/170786/1 "2005-11-29T16:14:27Z")

</div>

Hi im new to programming but ive cobbled together a script for a photo gallery.  
I have created and duplicated a mc, but now i want to load images into the boxes and scale them to fit!  
Will the original mc still work when clicked?

Here’s my code so far:

// create a container to put a movie clip in.  
var container:MovieClip = setUpContainer(“container1”);  
//var container:MovieClip = createEmptyMovieClip(“container”, getNextHighestDepth());

[//mcLoader.addListener](https://mcLoader.addListener)(this);  
[//mcLoader.loadClip](https://mcLoader.loadClip)(“photo1.jpg”, duplicate[5]);

//function onLoadInit(mc:MovieClip) {  
// trace("onLoadInit: " + mc);  
//}

var ln:Number = 10;  
// number of boxes  
var spacer:Number = 5;  
// size of spacer  
var duplicate:Array = new Array();  
// init array of movieclips

for (var i = 0; i\<(ln-1); i++) {  
// i from 0 to 9 ie 10 boxes  
var newX:Number = i\*(container.\_width+spacer);  
// calc y posit of new box  
duplicate\* = container.duplicateMovieClip(“clip-”+i, i+1);  
// duplicate container call it clip-1, clip-2 etc + assign it to member of duplicate array  
duplicate\*.\_x = newX;  
// set \_y property of duplicate container to new value.  
duplicate\*.onPress = function() {  
moveBox(this.\_name, duplicate);  
};  
var startX:Number = duplicate\*.\_x;  
trace(startX);

}

// Use MovieClipLoader to load the image.  
//var my\_mcl:MovieClipLoader = new MovieClipLoader();  
//my\_mcl.loadClip(“photo1.jpg”, container);

//duplicate[2].\_y = 300;  
//var mcLoader:MovieClipLoader = new MovieClipLoader();  
//for (i=0; i\<1; i++){  
[//mcLoader.loadClip](https://mcLoader.loadClip)(“photo” + i +".jpg", duplicate\*);  
[//container1.photo1.jpg](https://container1.photo1.jpg).\_xscale = 50;  
//}  
function setUpContainer(cName:String):MovieClip {  
var mc:MovieClip = this.createEmptyMovieClip(cName, this.getNextHighestDepth());  
// create movieclip call it cName and set depth  
var w:Number = 60;  
// width  
var h:Number = 60;  
// height  
mc.beginFill(0,100);  
// fill it with grey  
mc.lineTo(w, 0);  
// draw …  
mc.lineTo(w, h);  
mc.lineTo(0, h);  
mc.lineTo(0, 0);  
// … box  
mc.endFill();  
mc.\_visible = false;  
// make the first box invisible  
return mc;  
// return reference to Movieclip  
}  
function moveBox(clipName:String, arrayRef:Array) {  
var i:Number;  
for (i=0; i\<arrayRef.length; i++) {  
// if the name of the the box is the same as the name sent into the function…  
if (arrayRef\*.\_name == clipName) {  
// if it’s not at the top, tween it up  
if (arrayRef\*.\_y == 0) {  
ballTween = new mx.transitions.Tween(arrayRef\*, “\_y”, mx.transitions.easing.Regular.easeOut, arrayRef\*.\_y, 200, 30);  
ballTween = new mx.transitions.Tween(arrayRef\*, “\_rotation”, mx.transitions.easing.Regular.easeOut, 0, 360, 30);  
ballTween = new mx.transitions.Tween(arrayRef\*, “\_x”, mx.transitions.easing.Regular.easeOut, arrayRef\*.\_x, 250, 30);  
ballTween = new mx.transitions.Tween(arrayRef\*, “\_yscale”, mx.transitions.easing.Regular.easeOut, arrayRef\*.\_yscale, 200, 30);  
ballTween = new mx.transitions.Tween(arrayRef\*, “\_xscale”, mx.transitions.easing.Regular.easeOut, arrayRef\*.\_xscale, 300, 30);

```
			// otherwise tween it down.
		} else {
			ballTween = new mx.transitions.Tween(arrayRef*, "_y", mx.transitions.easing.Regular.easeOut, arrayRef*._y, 0, 30);
			ballTween = new mx.transitions.Tween(arrayRef*, "_alpha", mx.transitions.easing.Regular.easeOut, 100, 70, 30);
			ballTween = new mx.transitions.Tween(arrayRef*, "_x", mx.transitions.easing.Regular.easeOut, arrayRef*._x, i * 65, 30);
			ballTween = new mx.transitions.Tween(arrayRef*, "_yscale", mx.transitions.easing.Regular.easeOut, arrayRef*._yscale, 100, 30);
			ballTween = new mx.transitions.Tween(arrayRef*, "_xscale", mx.transitions.easing.Regular.easeOut, arrayRef*._xscale, 100, 30);
		}
		// if the box name doesn't match and the box is not at the top, tween it up
	} else if (arrayRef*._y != 0) {
		ballTween = new mx.transitions.Tween(arrayRef*, "_y", mx.transitions.easing.Regular.easeOut, arrayRef*._y, 0, 30);
		ballTween = new mx.transitions.Tween(arrayRef*, "_alpha", mx.transitions.easing.Regular.easeOut, 100, 70, 30);
		ballTween = new mx.transitions.Tween(arrayRef*, "_x", mx.transitions.easing.Regular.easeOut, arrayRef*._x, i * 65 , 30);
		ballTween = new mx.transitions.Tween(arrayRef*, "_yscale", mx.transitions.easing.Regular.easeOut, arrayRef*._yscale, 100, 30);
		ballTween = new mx.transitions.Tween(arrayRef*, "_xscale", mx.transitions.easing.Regular.easeOut, arrayRef*._xscale, 100, 30);
	}
}

```

}
