2 Replies Latest reply on Sep 22, 2009 11:27 AM by timo888

    exposing a method in an mxml component

    timo888 Level 1

      Trying to learn Flex Builder 3, so I created an mxml component consisting of three checkboxes on a Canvas. I told the dialog to extend Canvas.  In my HelloWord example project (WindowedApplication), I refer to this mxml component like this:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
      layout="vertical"  xmlns:TRComp="MyComponents.*"
           creationComplete = "initApp()" >


      <TRComp:TrioCheckBox id="myTrioCheckBox"/>

       

       

      and the custom widget with three checkboxes is correctly displayed when I run my HelloWorld WindowedApplication.

      So far so good!

       

      Now I wish to implement a public method in that mxml component

       

      So I've inserted into the mxlm definition of TrioCheckBox the following code block:

       

      <mx:Script>
              <![CDATA[
           
                  public function getCheckedValuesAsString():String
                  {
                     return "test";
                   
                  }
              ]]>
        </mx:Script>

       

      and here's how I'm invoking the method  in the HelloWorld app:

       

      <mx:Script>
              <![CDATA[
                
                         
                  public function initApp():void
                  {
                      mainTxt.text=myTrioCheckBox.getValuesAsString();
                  }
              ]]>
          </mx:Script>

       

      But when I do so, there is this error:

       

      1061: Call to a possibly undefined method getValuesAsString() through a reference with static type MyComponents:TrioCheckBox.

       

      What am I doing wrong? Why is the getValuesAsString() method "possibly undefined"?

      Thanks