# Noob question about .swf embedding

**URL:** <https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224>\
**Category:** flash\
**Created:** [June 13, 2008, 2:23pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224 "2008-06-13T14:23:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hapimp](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hapimp](https://forum.kirupa.com/u/hapimp)\
**Post date:** [June 13, 2008, 2:23pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/1 "2008-06-13T14:23:50Z")

</div>

Hi all

Im having a problem with a mov embedding in a swf file. What i want to achieve is to trigger a function when the swf file has stopped playing. For some odd reason i cant figure this out. My code is this:

```auto
import fl.motion.MotionEvent;
stop();

var pictLdr:Loader = new Loader();
var pictURL:String = "trafik1.swf"
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.load(pictURLReq);
trafik1_mc.addChild(pictLdr);
trafik1_mc.addEventListener(Event.COMPLETE, remove);

function remove(event:Event)
{
    trace("t");
    trafik1_mc.removeChild(pictLdr);
}

```

sorry for the noob question, hope you can help

/esben

---

<div class="post-metadata">

**Author:** ![MrTerrible](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@MrTerrible](https://forum.kirupa.com/u/MrTerrible)\
**Post date:** [June 13, 2008, 3:43pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/2 "2008-06-13T15:43:35Z")

</div>

[quote=hapimp;2342181]Hi all

Im having a problem with a mov embedding in a swf file. What i want to achieve is to trigger a function when the swf file has stopped playing. For some odd reason i cant figure this out. My code is this:

```auto

...
trafik1_mc.addEventListener(Event.COMPLETE, remove);
...

```

sorry for the noob question, hope you can help

/esben[/quote]

MovieClip has no Event.COMPLETE event.  
You may add your own event at the end of the swf, or you may check if it is still playing:

```auto

addEventListener(Event.ENTER_FRAME, onEnter);
function onEnter(evt:Event):void
{[INDENT]if (your_mc.currentFrame == your_mc.lastFrame) {removeMC()}
[/INDENT]}

```

It’s not the most beautiful solution, but it might work, I hope 🙂

---

<div class="post-metadata">

**Author:** ![hapimp](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hapimp](https://forum.kirupa.com/u/hapimp)\
**Post date:** [June 13, 2008, 4:17pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/3 "2008-06-13T16:17:23Z")

</div>

Thanks for your reply Terrible. Ive been messing about with it a bit, but it does not seem to work. It seems that your\_mc.currentFrame always returns 1. I guess that this is because the progression of frames takes place in the child og your\_mc? My problem then, is how to access the timeline of the child of your\_mc.

Anyone has an idea of how to get this?

PS. I also am having a bit of problems with lastFrame. Is this a AS3 thing? It doesnt ‘turn blue’ in my Flash document.

Thanks again,  
/esben

---

<div class="post-metadata">

**Author:** ![MrTerrible](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@MrTerrible](https://forum.kirupa.com/u/MrTerrible)\
**Post date:** [June 13, 2008, 4:33pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/4 "2008-06-13T16:33:39Z")

</div>

[quote=hapimp;2342258]  
PS. I also am having a bit of problems with lastFrame. Is this a AS3 thing? It doesnt ‘turn blue’ in my Flash document.

Thanks again,  
/esben[/quote]

Oppps, sorry. It should be ‘totalFrames’.

---

<div class="post-metadata">

**Author:** ![hapimp](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hapimp](https://forum.kirupa.com/u/hapimp)\
**Post date:** [June 13, 2008, 6:01pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/5 "2008-06-13T18:01:04Z")

</div>

Thank you, i changed it now. It does not make any difference though, since your\_mc currentFrame is always 1 (and so is totalFrames)?! I need to get to your\_mc’s child’s (pictLdr) timeline, and read the frames from there. any ideas?

/esben

---

<div class="post-metadata">

**Author:** ![hapimp](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@hapimp](https://forum.kirupa.com/u/hapimp)\
**Post date:** [June 13, 2008, 7:11pm UTC](https://forum.kirupa.com/t/noob-question-about-swf-embedding/263224/6 "2008-06-13T19:11:03Z")

</div>

Nevermind guys, i found another solution. Thanks for your time.

/esben
