Noob question about .swf embedding

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:

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

[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:


...
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:


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 :slight_smile:

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

[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’.

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

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

/esben