2 Replies Latest reply on Jan 8, 2012 10:23 PM by linn0102

    The instance can't be released.

    linn0102

      Precondition:

        1.Adobe Flash Player Version:11.1.102.56

        2.Module SubFrame.mxml has a chart and a monitor of his parent container-myFlex.mxml.

      Phenomenon:

        When I load SubFrame.swf more than once,the instance of SubFrame can't be released. But if I remove the chart or the monitor,the instance of SubFrame can be released.

      Problem:

        Can you tell me why both of the chart and the monitor exist,the instance can't be released ? How to solve this problem?

      Remarks:

        In Adobe Flash Player Version 10.0.45.2,this problem isn't exist.

       

       

      Code is as follows

          ----------

          myFlex.mxml

          ---------- 

          `<?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark"

          xmlns:mx="library://ns.adobe.com/flex/mx"

          creationComplete="initApp()">

          <fx:Script>

             <![CDATA[

          import mx.core.FlexGlobals;

          import mx.core.IVisualElementContainer;

          import mx.core.IVisualElement;

          import mx.events.ModuleEvent;

          import mx.modules.IModuleInfo;

          import mx.modules.ModuleManager;

         

          private static var moduleInfo:IModuleInfo;

         

          private function initApp():void{

          TestModel.topContainer=topH;

          }

         

          private function loadSubFrame():void{

          if (moduleInfo != null){

          moduleInfo.unload();

          moduleInfo.release();

          }

          moduleInfo=ModuleManager.getModule("SubFrame.swf");

          moduleInfo.addEventListener(ModuleEvent.READY, onModuleReady, false, 0, true);

          moduleInfo.load();

          }

         

          public function onModuleReady(evt:ModuleEvent):void{

          mainH.removeAllElements();

          mainH.addElement(moduleInfo.factory.create() as IVisualElement);

          }

          ]]>

          </fx:Script>

          <s:HGroup id="topH">

          </s:HGroup>

         

          <s:HGroup>

          <s:Button label="load line" click="loadSubFrame()"/>

          <s:HGroup id="mainH" width="100%" height="100%"/>

          </s:HGroup>

         

          </s:Application>

         

         

          ----------

          SubFrame.mxml

          ----------

         

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"

             xmlns:s="library://ns.adobe.com/flex/spark"

             xmlns:mx="library://ns.adobe.com/flex/mx"

             creationComplete="init()">

         

          <fx:Script>

          <![CDATA[

          public function init():void {

             TestModel.topContainer.addEventListener("change", changeHandler, true, 0, true);

          }

            

          public function changeHandler(e:Event):void {

             

          }

            

          ]]>

          </fx:Script>

          

          <mx:LineChart/>

          

          </mx:Module>

         

          ----------

          TestModel.as

          ----------

          package

          {

          import spark.components.HGroup;

          import mx.core.IVisualElementContainer;

          public class TestModel

          {

          static public var topContainer:HGroup;

         

          static public var mainContainer:IVisualElementContainer;

           }

          }