# Loaded object won't accept mouse clicks

**URL:** https://forum.kirupa.com/t/loaded-object-wont-accept-mouse-clicks/266165
**Category:** flash
**Created:** [July 16, 2008, 9:58pm UTC](https://forum.kirupa.com/t/loaded-object-wont-accept-mouse-clicks/266165 "2008-07-16T21:58:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![iwanczuk](https://avatars.discourse-cdn.com/v4/letter/i/c89c15/32.png) [@iwanczuk](https://forum.kirupa.com/u/iwanczuk)
#### Post date: [July 16, 2008, 9:58pm UTC](https://forum.kirupa.com/t/loaded-object-wont-accept-mouse-clicks/266165/1 "2008-07-16T21:58:44Z")

</div>

I’d appreciate any advice on why the following code won’t work. The problem is that the eventListeners for mouse clicks are not being acted upon. Thanks in advance…

package {  
import flash.events._;  
import [flash.net](http://flash.net)._;  
import flash.display.\*;

```
public class test extends Sprite {

    public var currentAssembly = new Sprite;
    public var currentAssemblyLoader:Loader = new Loader();
    public var currentAssemblyURL:URLRequest = new URLRequest();
    public var loadedAssemblyArray:Array = new Array();
    
    public var currentAssemblyPointer= new int;
    
    public function test():void {
        currentAssemblyLoader.contentLoaderInfo.addEventListener(Event.INIT, assemblyLoaded, false, 0, true);
        currentAssemblyLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress, false, 0, true);
        currentAssemblyLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
        currentAssemblyLoader.load(new URLRequest("http://panelec.twoslackers.com/graphics/CBAT1L1.swf") );
    }
    
    public function assemblyLoaded(evt:Event):void {    
        var theSWF:DisplayObject = evt.target.content;
        
        var index = new int;
    
        currentAssemblyLoader.unload();
        index = loadedAssemblyArray.length;
        loadedAssemblyArray[index] = theSWF;
        loadedAssemblyArray[index].x = 10;
        loadedAssemblyArray[index].y = 10;
        loadedAssemblyArray[index].scaleX = .75;
        loadedAssemblyArray[index].scaleY = .75;
        loadedAssemblyArray[index].addEventListener(MouseEvent.MOUSE_DOWN, currentAssemblyMouseDown, false, 0 , true);
        loadedAssemblyArray[index].addEventListener(MouseEvent.MOUSE_UP, currentAssemblyMouseUp, false, 0 , true);
        addChild(loadedAssemblyArray[index] );
    }

    function currentAssemblyMouseDown(evt:Event):void {
        currentAssemblyLoader.load(new URLRequest("http://panelec.twoslackers.com/graphics/CBAT1L1.swf") );
        evt.target.startDrag();
        trace("click");
    }

    function currentAssemblyMouseUp(evt:Event):void {
        evt.target.stopDrag();
    }

    public function loadProgress(evt:ProgressEvent):void {
        trace("loading");
    }
    
    public function onIOError(evt:IOErrorEvent):void {
        trace("Unable to load data.");
    }
}

```

}
