tags:

views:

166

answers:

0

I have a main app which calls a pop-up where the user selects the name of an article to view. The pop-up in turn calls a function in the main app which loads the viewer module if not already open and then sets the url on the viewer to load the .swf file.

In mainApp

public var moduleLibrary:Object;
public var displayObject:DisplayObject;

public function loadSWF(strFileName:String):void
{
    moduleLibrary.fpViewer.SwfFile = strFileName;
}

private function moduleHandler(moduleUrl:String):void
{
    moduleInfo = ModuleManager.getModule(moduleUrl);
    moduleInfo.addEventListener(ModuleEvent.READY, readyHandler);
    moduleInfo.addEventListener(ModuleEvent.ERROR, errorHandler);
    moduleInfo.load();
}

private function readyHandler(event:ModuleEvent):void
{
    moduleLibrary = moduleInfo.factory.create();

    displayObject = moduleInfo.factory.create() as DisplayObject;
    moduleLoader.addChild(displayObject);
    FadeEffect(displayObject, 1000, 0, 0, 1);
    currentState = "";
}

In modViewer

<mx:Canvas width="880" height="530">
    <fp:FlexPaperViewer id="fpViewer" x="0" y="0" width="100%" height="100%" Scale="1.0" />
</mx:Canvas>

The problem lies in the line "moduleLibrary.fpViewer.SwfFile". The value of fpViewer is ALWAYS null but the similar assignment of "displayObject = moduleInfo.factory.create() as DisplayObject;" is ALWAYS correct (although the function can't be called through it).

Thanks for your help and constructive comments.