# UILoader preloader problem

**URL:** <https://forum.kirupa.com/t/uiloader-preloader-problem/295297>\
**Category:** flash\
**Created:** [August 27, 2009, 7:39pm UTC](https://forum.kirupa.com/t/uiloader-preloader-problem/295297 "2009-08-27T19:39:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![szox](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@szox](https://forum.kirupa.com/u/szox)\
**Post date:** [August 27, 2009, 7:39pm UTC](https://forum.kirupa.com/t/uiloader-preloader-problem/295297/1 "2009-08-27T19:39:49Z")

</div>

this is how it works. i add gallery mc to stage by this code:

```auto
var galleryPage = new pageGallery();
galleryPage.stop();
gallery_mc.addEventListener(MouseEvent.CLICK, btnClick);
gallery_mc.targetMc = galleryPage;

function btnClick(e:MouseEvent):void
{...
addChild(currentPage.targetMc);
currentPage.targetMc.gotoAndPlay(1);
..}

```

inside galeryPage there is UIloader added to stage with parameters set to load an external file - gallery.swf.

here is UILoader event code(its written at galleryPage frame):

```auto
stop();

myLoader.addEventListener(Event.COMPLETE, fadeIn);

function fadeIn(e:Event):void
{
    trace("loaded");
    preloader_mc.alpha=0;
    new Tween(myLoader,"alpha",Strong.easeOut,0,1,1,true);
}

```

testing movie traces “loaded” straight away just afer comilation is finished. when i go to the galeryPage preloader\_mc is already set to alpha=0;  
why is the event completed so early and not after going to the galleryPage? how to make it work?
