# \[AS2\] attach mc's, show 6 of array.length

**URL:** https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999
**Category:** flash
**Created:** [June 11, 2008, 6:33pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999 "2008-06-11T18:33:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![munklemoose](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@munklemoose](https://forum.kirupa.com/u/munklemoose)
#### Post date: [June 11, 2008, 6:33pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/1 "2008-06-11T18:33:05Z")

</div>

Hi all,

I am attaching mc’s from the library using xml to populate the textfields. What I am wanting to do is show the first six mc’s, then after say 10 seconds show the next six. With a text field displaying “1 of 3”, after 10 seconds, “2 of 3” …etc.  
A bit similar to image galleries really (sorry if I haven’t explained this very well).

Anyhoo, heres what I have so far, it loads the mc’s one after each other:

```auto

import mx.transitions.Tween;
import mx.transitions.easing.*;

//Time in seconds its displayed
var displayTime = 10;

//Spacing between items
var event_spacing = 56;

var eventArray:Array = [];
GenerateEventListing = function (eventContent_xml, target_mc) {
    var events = eventContent_xml.firstChild.childNodes;
    var counter = 0;
    function doTween(target_mc, index) {
        var event_mc = target_mc.attachMovie("event", "event" + index, index);
        event_mc.node = events[index];
        event_mc._y = index * event_spacing;
        var pushed:Number = eventArray.push(event_mc);
        event_mc.txt_mc.title_txt.text = events[index].childNodes[1].childNodes[0].nodeValue;
        event_mc.txt_mc.info_txt.text = events[index].childNodes[2].childNodes[0].nodeValue;
        var myTween = new Tween(event_mc, "_x", Strong.easeOut, 200, 0, .4, true);
        myTween.onMotionFinished = function() {
            if (++index != events.length){
                doTween(target_mc, index);
            }
        };
    }
    doTween(target_mc, counter);
};

// Timer event
countDown = function () {
     displayTime--;
     if (displayTime == 0) {
        clearInterval(timer);
        for (var i:Number = 0; i <= eventArray.length; i++) {
            var myTweenOut = new Tween(eventArray*, "_x", Strong.easeOut,0, -400, .4, true);
        }
     }
};
timer = setInterval(countDown, 1000);

// Load XML
var eventContent_xml = new XML();
eventContent_xml.ignoreWhite = true;
eventContent_xml.onLoad = function(success){
    if (success){
        GenerateEventListing(this, playlist_mc);
    }else trace("Error loading XML file");
}
eventContent_xml.load("../xml/eventContent.xml");

```

Thanks for any help on this!

---

<div class="post-metadata">

### Author: ![munklemoose](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@munklemoose](https://forum.kirupa.com/u/munklemoose)
#### Post date: [June 12, 2008, 10:32pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/2 "2008-06-12T22:32:24Z")

</div>

anyone any idea on this please?

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 12, 2008, 10:58pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/3 "2008-06-12T22:58:37Z")

</div>

post up your files so I dont have to replicate your program…xml and images too

---

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [June 12, 2008, 11:36pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/4 "2008-06-12T23:36:46Z")

</div>

here maybe you can get an idea from this

---

<div class="post-metadata">

### Author: ![munklemoose](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@munklemoose](https://forum.kirupa.com/u/munklemoose)
#### Post date: [June 16, 2008, 10:04am UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/5 "2008-06-16T10:04:14Z")

</div>

Thanks for the files, looks like it will help me alot!!

Cheers again

---

<div class="post-metadata">

### Author: ![munklemoose](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@munklemoose](https://forum.kirupa.com/u/munklemoose)
#### Post date: [June 16, 2008, 2:43pm UTC](https://forum.kirupa.com/t/as2-attach-mcs-show-6-of-array-length/262999/6 "2008-06-16T14:43:18Z")

</div>

My xml is created from an access database using asp. the xml looks like this:

```auto

<events>
<eventID>
 <headline>event 1</headline>
 <story>new event UPDATE</story>
 <date>10/06/2008</date>
</eventID>
<eventID>
 <headline>event 2</headline>
 <story>asdfasdf</story>
 <date>10/06/2008</date>
</eventID>
<eventID>
 <headline>event 3</headline>
 <story>wa da fa!</story>
 <date>11/06/2008</date>
</eventID>
<eventID>
 <headline>event 4</headline>
 <story>wa da fa!</story>
 <date>11/06/2008</date>
</eventID>
<eventID>
 <headline>event 5</headline>
 <story>wa da fa!</story>
 <date>11/06/2008</date>
</eventID>
<eventID>
 <headline>event 6</headline>
 <story>wa da fa!</story>
 <date>11/06/2008</date>
</eventID>
<eventID>
 <headline>event 7</headline>
 <story>wa da fa!</story>
 <date>11/06/2008</date>
</eventID>
</events>

```

What I was trying to achieve was that the flash shows the first 6 of the events, then the remaining event after 5 seconds.

was trying to re-work your example, but cant get it working
