Search code examples
actionscript-3flashbuilder4

How to use an external actionscript file with flex


I'm building a Flash 4 Builder project and want to use an external actionscript file. Here is the structure I used...

http://img704.imageshack.us/img704/794/schermafbeelding2010121b.png

So, I want to be able to connect "actionscript.as" to the "OrderApp.mxml" file.

I add this <fx:Script source="assets/actionscript/actionscript.as"/> to my OrderAp.mxml file and a function in actionscript.as looks for example like this:

public function checkCode():void{
    if (txtToegangscode.text == "moia") {
        lblFeedback.text = "ok";
        txtToegangscode.enabled = false;
        btnGaNaarPersonen.visible = true;
        btnGaVerder.visible = false;
    } else {
        lblFeedback.text = "wrong"; 
    }
}

When I want to add some components, like "Toegangscode.mxml" I keep getting errors like "1120: Acces of undefined property lblFeedback". When I try to call the function checkCode() What do I do wrong?


Solution

  • Looks like you are missing the double quote at the start of the string?

    lblFeedback.text = wrong";

    should be...

    lblFeedback.text = "wrong";

    Why not put this code into a class then you can detect any compile errors?