# AS3: add event listener to loaded AS2 SWF

**URL:** https://forum.kirupa.com/t/as3-add-event-listener-to-loaded-as2-swf/330323
**Category:** flash
**Created:** [January 2, 2013, 10:32am UTC](https://forum.kirupa.com/t/as3-add-event-listener-to-loaded-as2-swf/330323 "2013-01-02T10:32:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Flivor2012](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@Flivor2012](https://forum.kirupa.com/u/Flivor2012)
#### Post date: [January 2, 2013, 10:32am UTC](https://forum.kirupa.com/t/as3-add-event-listener-to-loaded-as2-swf/330323/1 "2013-01-02T10:32:30Z")

</div>

Hi,  
What I am trying to do is - simply load an external SWF into my AS3 code.  
I then want to show it on my stage - and be able to catch the ‘ROLL\_OVER’, ‘ROLL\_OUT’ and ‘MOUSE\_CLICK’ events that happen with the SWF,  
meaning - I want to know when the user hovers over the loaded SWF and when he clicks on it.

If I load an external **AS3 SWF** - it all works fine, and I can trace the events successfully.

If I load an external **AS2 SWF** - in some types of AS2 banners I can catch the events, and in some - I can’t.

It is important to note that I cannot control the loaded SWFs and I cannot code them in a different manner.

The way I load the external SWFs is like this:

```auto

var loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded);
loader.load(new URLRequest(externalSwfURL));

function onLoaded(evt:Event):void
{
    // The reason I don't create the MovieClip like this is because I need to support 
    // both AS2 and AS3 that will be loaded, and loaded AS2 cannot be casted to 'MovieClip'
    //var mc:MovieClip = MovieClip(evt.target.content);  

    // This method allows me to load both external AS2 and AS3 SWF files
    var mc:MovieClip = new MovieClip();
    mc.addChild(loader);

    // Add the events that I want to track
    mc.addEventListener(MouseEvent.ROLL_OVER , onMouseEnterSWF);
    mc.addEventListener(MouseEvent.ROLL_OUT , onMouseLeaveSWF);
    mc.addEventListener(MouseEvent.CLICK , onMouseClickSWF);

    mc.x = 100;
    mc.y = 100;

    stage.addChild(mc);
   }

```

What I have found out is that if the loaded AS2 SWF has a transparent button on top of it (a lot of them have that) -  
then the mouse events aren’t fired back up to my AS3 code ! They are somehow ‘swallowed’ inside the loaded AS2 SWF and not bubbled up.

If I try to load an AS3 SWF that has a transparent button as the top layer - it works, and still bubbles up the mouse events to my AS3 code.

Can anyone tell me why this happens ?

PS - if I load an AS2 SWF that doesn’t have a transparent button as a top layer - than the mouse events ARE bubbled up to my AS3 code.

Here is a link to an AS2 SWF file that has the ‘transparent button’ that blocks the events from bubbling up to the AS3 code:  
[http://www.filedropper.com/jdatebanner-copy](http://www.filedropper.com/jdatebanner-copy)
