2 Replies Latest reply on Mar 11, 2009 11:11 AM by Philip_King

    Problem calling AS3 class's methods from Flex Project

    Philip_King
      Sorry if this is a stupid question, but after 2 days of Web searching and 2 books give up; I am a Java and c# programmer and am having problems calling AS3 classes (in packages) from Flex Builder 2 Flex Projects; the AS3 classes work great as Flex Builder "AS3 Projects", but when I try to use the classes in a Flex Builder "Flex Project" I am able to see and set their properties, but cannot see (through "code completion") their methods (unless the class extends another AS3 class; and in that case I can see the base class's methods). Here is the code:

      AS3 Example Class:

      package asText {
      public class CheckWord {
      public var strData:String;
      public var strAProperty:String;
      public var intAProperty:int;

      // Constructor
      public function CheckWord() {
      }

      public function TestMethod():void {
      trace("test...");
      }

      public function WordLength():int {
      var intLength:int = 0;
      trace(strData);
      intLength = strData.length;
      return intLength;
      } // From Method WordLength
      } // From Class CheckWord
      } // From Package asText

      ***********************************************************************
      The MXML code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      width="442" height="488" horizontalAlign="center" verticalAlign="middle"
      backgroundGradientColors="[#c0c0c0, #c0c0c0]"
      xmlns:asTheText="asText.*"
      >

      <asTheText:CheckWord strData="Test words" />

      <mx:Panel title="Welcome to ........" width="337" height="393" horizontalAlign="center" verticalAlign="middle" layout="absolute" y="15" x="50">
      <mx:Text text="First Name" enabled="true" width="68" fontWeight="bold" x="27.25" y="36"/>
      <mx:TextInput id="txtFName" x="112.25" y="34"/>
      <mx:Text text="Last Name" enabled="true" width="68" fontWeight="bold" x="27.25" y="66"/>
      <mx:TextInput x="112.25" y="64" id="txtLName"/>
      <mx:Text text="email address" enabled="true" width="87" fontWeight="bold" x="17.25" y="96"/>
      <mx:TextInput width="189" id="txtEmail" left="112.25" top="94"/>
      <mx:Button id="butSubmit" label="Submit" x="95" y="194" click="asTheText:TestMethod();"/>
      ..............and so on ............

      ***************************************************

      All this does is give me an 1180 error:
      1180: Call to a possibly undefined method TestMethod. flexConveyMovie1.mxml