# Lifecycle of a .swf

**URL:** <https://forum.kirupa.com/t/lifecycle-of-a-swf/185418>\
**Category:** Uncategorized\
**Created:** [April 13, 2006, 8:59am UTC](https://forum.kirupa.com/t/lifecycle-of-a-swf/185418 "2006-04-13T08:59:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ice987](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@ice987](https://forum.kirupa.com/u/ice987)\
**Post date:** [April 13, 2006, 8:59am UTC](https://forum.kirupa.com/t/lifecycle-of-a-swf/185418/1 "2006-04-13T08:59:11Z")

</div>

I have a .fla which loads 2 swfs. Each swf plays an animation. I only have the .swfs and not the .flas so I cannot add code to the animations themselves. I want the 2nd swf to play when the first is finished. Is it possible for my .fla to monitor the first loaded clip for when it ends and then play the second one. Would the onUnload() handler help?

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 13, 2006, 9:14am UTC](https://forum.kirupa.com/t/lifecycle-of-a-swf/185418/2 "2006-04-13T09:14:47Z")

</div>

thats odd - it would be really easy if you had the flas for the 2 swfs…

my guess would be to use stop(); on the 2nd swfs holder movie clip as soon as it loads (so youll need to see if getBytesLoaded() == getBytesTotal() and then do that)

and then test in an onEnterFrame what the currentframe of the first swfs movie clip is, then when its at the last frame - do a play() on the 2nd one…

but it would be much smarter to just get the flas 😛

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [April 13, 2006, 9:41am UTC](https://forum.kirupa.com/t/lifecycle-of-a-swf/185418/3 "2006-04-13T09:41:28Z")

</div>

If it’s a timeline animation you could try this

```auto
box.loadMovie("m1.swf");
var ctrl = this.createEmptyMovieClip("ctrl", 99);
ctrl.onEnterFrame = function() {
	if (box._currentframe == box._totalframes) {
		box.loadMovie("m2.swf");
		delete this.onEnterFrame;
	}
};

```

scotty(-:
