1 Reply Latest reply on Sep 23, 2011 10:14 AM by Flex harUI

    Accessing modules from the parent application

    Yue_Hong Level 1

      I got not syntax error in Flex, but when I try to run it, I got this error message:

       

      ArgumentError: Error #2004: One of the parameters is invalid.

          at flash.display::Graphics/drawRect()

          at spark.components.supportClasses::TextBase/updateDisplayList()[E:\dev\4.5.1\frameworks\pro jects\spark\src\spark\components\supportClasses\TextBase.as:714]

          at mx.core::UIComponent/validateDisplayList()[E:\dev\4.5.1\frameworks\projects\framework\src \mx\core\UIComponent.as:8989]

          at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.5.1\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:736]

          at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:801]

          at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1180]

       

      How can I fix it? Thanks.

       

       

      Parent Application:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                             xmlns:s="library://ns.adobe.com/flex/spark" 
                             xmlns:mx="library://ns.adobe.com/flex/mx">
          <fx:Script>
              <![CDATA[
                  [Bindable]
                  private var s:String;
                  
                  private function getTitle():void {
                      s = (m1.child as subapp).getModTitle();
                  }    
              ]]>
          </fx:Script>
          <s:layout>
              <s:VerticalLayout/>
          </s:layout>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:Label id="displayLbl" text="This is Main Program"/>
          <s:ModuleLoader url="subapp.swf" id="m1" ready="getTitle()"/>
      </s:WindowedApplication>
      

       

       

      Module (subapp.swf):

       

      <?xml version="1.0" encoding="utf-8"?>
      <s: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" width="400" height="300">
          <fx:Script>
              <![CDATA[
                  public function getModTitle():String {
                      return "abc";
                  }
              ]]>
          </fx:Script>
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:Label text="This is sub Program"/>
      </s:Module>