# Scrolling gallery preloader problem

**URL:** <https://forum.kirupa.com/t/scrolling-gallery-preloader-problem/320667>\
**Category:** Uncategorized\
**Created:** [March 29, 2011, 9:41pm UTC](https://forum.kirupa.com/t/scrolling-gallery-preloader-problem/320667 "2011-03-29T21:41:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh3](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Josh3](https://forum.kirupa.com/u/Josh3)\
**Post date:** [March 29, 2011, 9:41pm UTC](https://forum.kirupa.com/t/scrolling-gallery-preloader-problem/320667/1 "2011-03-29T21:41:55Z")

</div>

Hi

I am fairly new to actionscript and I got this script online here [http://www.republicofcode.com/tutorials/flash/imagegallery/](http://www.republicofcode.com/tutorials/flash/imagegallery/)  
for a scrolling image gallery.

I have been struggling to add a preloader to it. I create another frame before the frame that contains the action, place my preloader code in there, when i test it. It just gives me a blank screen until the animation loads.  
I can not for the life of me get it to display the loading animation.  
I have tried loads of tutorials.

I suspect its something to do with this line “this.createEmptyMovieClip(“container”,1);”

The code i have is as follows:  
"  
import mx.transitions.Tween;  
import mx.transitions.easing.\*;

stop();

this.createEmptyMovieClip(“container”,1);  
var imagesNumber:Number = 26;  
var scrolling:Boolean = true;

for (i=1; i\<=imagesNumber; i++) {  
container.attachMovie(“thumb”+i,“thumb”+i+"\_mc",i);  
myThumb\_mc = container[“thumb”+i+"\_mc"];  
myThumb\_mc.\_x = (i-1)\*myThumb\_mc.\_width;  
myThumb\_mc.\_y = (Stage.height-myThumb\_mc.\_height)/2;  
myThumb\_mc.\_alpha = 50;  
myThumb\_mc.largerImage = i;  
myThumb\_mc.onRollOver = function() {  
this.\_alpha = 100;  
};  
myThumb\_mc.onRollOut = function() {  
this.\_alpha = 50;  
};  
myThumb\_mc.onRelease = function() {  
this.\_alpha=50;  
for (i=1; i\<=imagesNumber; i++) {  
var myClip = container[“thumb”+i+"\_mc"];  
myClip.enabled = false;  
}  
scrolling = false;  
\_root.attachMovie(“image”+this.largerImage,“large\_mc”,2);  
large\_mc.\_x = (Stage.width-large\_mc.\_width)/2;  
large\_mc.\_y = (Stage.height-large\_mc.\_height)/2;  
new Tween(large\_mc, “\_alpha”, Strong.easeOut, 0, 100, 0.5, true);  
new Tween(container, “\_alpha”, Strong.easeOut, 100, 50, 0.5, true);  
large\_mc.onRelease = function() {  
this.enabled=false;  
scrolling = true;  
var myFadeOut = new Tween(large\_mc, “\_alpha”, Strong.easeOut, 100, 0, 0.5, true);  
new Tween(container, “\_alpha”, Strong.easeOut, 50, 100, 0.5, true);  
myFadeOut.onMotionFinished = function() {  
for (i=1; i\<=imagesNumber; i++) {  
var myClip = container[“thumb”+i+"\_mc"];  
myClip.enabled = true;  
}  
large\_mc.removeMovieClip();  
};  
};  
};  
}  
container.onEnterFrame = function() {  
if (scrolling) {  
this.\_x += Math.cos((-\_root.\_xmouse/Stage.width)\*Math.PI)\*14;  
if (this.\_x\>0) {  
this.\_x = 0;  
}  
if (-this.\_x\>(this.\_width-Stage.width)) {  
this.\_x = -(this.\_width-Stage.width);  
}  
}  
};"

Any help would be greatly greatly appreciated.

Thanks
