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.;
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.");
}
}
}