2 Replies Latest reply on Oct 1, 2010 3:06 AM by WolframPl

    Unable to access MXML function - MANY thanks for quick help

    WolframPl

      Hi all,

      I really got stuck for many hours now, as I think this really is a simple task to achieve. So I need your help.

      Assuming I have two files: A.mxml contains the main application and also opens my components in B, B.mxml contains additional components.

       

      <?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"
                             creationComplete="init();"
                             xmlns:mycomp="*">

       

          <fx:Script>
              <![CDATA[
                 
                  private function init():void
                  {
                      // this is what does not work
                      mycomp:Button1.set();

                  }
              ]]>
          </fx:Script>
         
          <mycomp:B/>
         
      </s:WindowedApplication>

       

      and here is my component B that should be invoked:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group 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 set():void
                  {
                      // whatever needs to be done here
                      // setting the label is just an example
                      Button1.label = "abc";

                  }
              ]]>
          </fx:Script>
          <s:Button x="55" y="47" label="Button1" id="Button1" />
      </s:Group>

       

      Of course, putting all in a single file is easy. But how can I access a public function within B from my main application (and in addition from another .as-file).

      I assume the answer is more than easy, but even after lots of searching I could not find it.

       

      Thanks,

      Wolfram