Solve the call to undefined property problem – Flex

adobe flex logoLet’s all admit that we love Flex. It’s the way that the new wave of developers should write code.

The current version 3.0 is quite buggy, since this is the first mainstream release (yes, version 2.0 was the big release, but 3.0 has more hands-on testers).  Anyways, we will try to fix a common error that is produced from the Database Wizard.

When we built our application (web or Air , it doesn’t matter, the error is the same) from the Database Wizard, Flex produces 3 files. The MXML file with the source code, *Script.as with the necessary actionscript code to handle all the database functions, such as Insert, Update, Delete, and the *config.as  which contains some irrelevant (to this tutorial) code.

If you start messing with the source code in the MXML file, you will probably get the “Call to undefined property…” error. To fix this you need to follow the following steps:

  • Select and copy all the contents of your *Script.as file
  • Go to the line <mx:Script source=”*Script.as” /> and remove source=”*Script.as” / (don’t forget the trailing slash) and it should look like <mx:Script >
  • Now close the Script with </mx:Script>
  • Between the tags <mx:Script></mx:Script> paste the contents of the *Script.as file.
  • Save & Error gone!

This error occurs because the file *Script.as is loaded to the application as a class and not a script. If this tutorial helped you please leave feedback.