# AS3 Fade images in and out randomly

**URL:** https://forum.kirupa.com/t/as3-fade-images-in-and-out-randomly/318189
**Category:** flash
**Created:** [January 12, 2011, 5:00pm UTC](https://forum.kirupa.com/t/as3-fade-images-in-and-out-randomly/318189 "2011-01-12T17:00:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jimjiminyjimjim](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jimjiminyjimjim](https://forum.kirupa.com/u/jimjiminyjimjim)
#### Post date: [January 12, 2011, 5:00pm UTC](https://forum.kirupa.com/t/as3-fade-images-in-and-out-randomly/318189/1 "2011-01-12T17:00:54Z")

</div>

I’m currently looking at a tutorial that loads thumbnails in from XML.

I’m deconstructing it to try and get used to AS3. Here is the bit I’m stuck on:

```auto

function thumbLoaded(e:Event):void {
    var my_thumb:Loader = Loader(e.target.loader);
    container_mc.addChild(my_thumb);
    my_tweens[Number(my_thumb.name)]=new Tween(my_thumb, "alpha", Strong.easeIn, 0,1,0.5, true);
    my_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);
}

```

The Tweens seem to be loaded into an array with

```auto
 var my_tweens:Array = [];

```

But once these thumbnails are loaded and fade in I would like them to fade in and out again with a given pause in between. Maybe even varying the pause for each thumbnail.

Now that the tweens are in an array - how do I start fading them in and out again. I’ve tried:

```auto

my_tweens[Number(my_thumb.name)].addEventListener(TweenEvent.MOTION_FINISH, onFinish);

```

But it comes up with all sorts of errors.

What would be the best way to approach this?
