# EventListener for frame number?

**URL:** <https://forum.kirupa.com/t/eventlistener-for-frame-number/306435>\
**Category:** flash\
**Created:** [March 15, 2010, 2:19pm UTC](https://forum.kirupa.com/t/eventlistener-for-frame-number/306435 "2010-03-15T14:19:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![weedunc65](https://avatars.discourse-cdn.com/v4/letter/w/73ab20/32.png) [@weedunc65](https://forum.kirupa.com/u/weedunc65)\
**Post date:** [March 15, 2010, 2:19pm UTC](https://forum.kirupa.com/t/eventlistener-for-frame-number/306435/1 "2010-03-15T14:19:57Z")

</div>

I am making a website, I have a loaded swf that I want to animate off screen AND THEN unload on a button click, the home button in this case. I have had a shot at making this happen but to no avail…

This is the code I have, which currently doesn’t work. The function ‘frame30’ does not fire. I have annotated it so you can see what works and what doesnt.

function mouseclickhome(event:MouseEvent):void{  
homebtn.gotoAndPlay(3); //button animation

var loadedswf:Object=loader.content;  
loadedswf.gotoAndPlay(16); //the loaded swf animates offscreen fine with this command

loadedswf.addEventListener(Event, frame30); //This is where it stops working, I’m pretty sure this is not correct

function frame30(e:Event):void //this function is not fired, trace is never returned  
{  
trace(“function fired”);  
if (loadedswf.currentFrame == 30) //once the loaded swf has reached frame 30 the animation is complete and the loader can be unloaded  
{  
loader.unload();  
gotoAndStop(2); //website background change  
}  
}

}

Many thanks in advance

Duncan
