編集:
申し訳ありませんが、あなたの質問を注意深く見ていませんでした。
あなたの問題は、 *.as ファイルがあなたのコンポーネントが何であるかを知らないということです:
次のようにコンポーネントを関数に渡す必要があります。
public function checkCode(txtToegangscode:TextInput, lblFeedback:Label):void{
if (txtToegangscode.text == "moia") {
lblFeedback.text = "ok";
txtToegangscode.enabled = false;
btnGaNaarPersonen.visible = true;
btnGaVerder.visible = false;
} else {
lblFeedback.text = "wrong";
}
これにより、*.as ファイルがそれらのコンポーネントのプロパティにアクセスできるようになります。
年:
ドキュメントは次のとおりです。http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_4.html
タグの source 属性を使用して、Flex アプリケーションに外部 ActionScript ファイルを含めます。これにより、MXML ファイルが整理され、さまざまなアプリケーション間でのコードの再利用が促進されます。
スクリプト ファイルにアプリケーション ファイルと同じ名前を付けないでください。これにより、コンパイラ エラーが発生します。
次の例は、IncludedFile.as ファイルの内容を示しています。
// usingas/includes/IncludedFile.as
public function computeSum(a:Number, b:Number):Number {
return a + b;
}
次の例では、IncludedFile.as ファイルの内容をインポートします。このファイルは、includes サブディレクトリにあります。
<?xml version="1.0"?>
<!-- usingas/SourceInclude.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script source="includes/IncludedFile.as"/>
<mx:TextInput id="ta1st" text="3" width="40" x="170" y="24" textAlign="right"/>
<mx:TextInput id="ta2nd" text="3" width="40" x="170" y="52" textAlign="right"/>
<mx:TextArea id="taMain" height="25" width="78" x="132" y="82" textAlign="right"/>
<mx:Button id="b1" label="Compute Sum"
click="taMain.text=String(computeSum(Number(ta1st.text), Number(ta2nd.text)));"
x="105"
y="115"
/>
<mx:Label x="148" y="52" text="+" fontWeight="bold" fontSize="17" width="23"/>
</mx:Application>
タグの source 属性は、相対パスと絶対パスの両方をサポートしています。
タグの source 属性と include ディレクティブは、さまざまな方法でファイルを参照します。
タグの source 属性で参照される外部ファイルへの有効なパスは次のとおりです。
../myscript.as などの相対 URL。スラッシュで始まらない相対 URL は、それを使用するファイルに対して相対的に解決されます。タグが「mysite/myfiles/myapp.mxml」に含まれている場合、システムは「mysite/IncludedFile.as」を検索します。
ActionScript の include ディレクティブでは、相対 URL のみを参照できます。Flex は、インポートされたクラスとパッケージのソース パスを検索します。Flex は、include ディレクティブまたはタグの source 属性を使用してインクルードされたファイルのソース パスを検索しません。