4 Replies Latest reply on Sep 25, 2008 12:55 PM by Graeme_Smith

    SWFLoader load and unload

    Graeme_Smith
      I have a main Application which calls a Module....
      Then that module loads child applications.
      for example:

      <mx:states>
      <mx:State name="OrgState">
      <mx:AddChild relativeTo="{SWFContainer}" position="firstChild">
      <mx:SWFLoader id="OrgSWFLoader"
      width="100%" height="100%"
      source="Organization.swf" autoLoad="false"
      verticalAlign="top" horizontalAlign="center"/>
      </mx:AddChild>
      <mx:SetProperty target="{DBPanel}" name="height" value="{dispAreaHt + 10}"/>
      <mx:SetProperty target="{DBCanvas}" name="height" value="{dispAreaHt + 10}"/>
      </mx:State>

      there's a dozen like this then within the action script, The user clicks on an image for the page they want to goto, for example:

      private function setupOrgsSubMenuClick():void
      {
      clearsetupSubMenuSelection();
      setupOrgsSubMenu.source="images/ERP_SetupOrgsSel.jpg";
      loadSWFComponent("OrgState");
      }

      Before the user selects the SWFLoader (eg. OrgSWFLoader = null). Then I load the SWF component like this:

      private function loadSWFComponent(newState:String):void
      {
      if (Application.application.IsActiveSession() == false)
      return;

      unloadPrevSWFFile();

      currentState = newState;

      if(currentState == "OrgState")
      {
      OrgSWFLoader.load("Organization.swf");
      }
      And the OrgSWFLoader has variables in it (all works as I want it so far). Then, at the moment, my unload looks like this:

      private function unloadPrevSWFFile():void
      {
      if(currentState == "OrgState")
      {
      OrgSWFLoader.source = "";
      }

      but it does not make the OrgSWFLoader = null again.

      Any thoughts?
      Help is appreciated, thanks in advance.