Don't Use Delete for a CFC function Name if You Want to Call The Function From Flex

I was creating a new Flex 2.0 application using CFC's to do the create, read, update, and delete work in the database. While testing the delete CFC function from within Flex I got a syntax error when compiling if I tried to do ProgramDAO.delete( aProgramObj ).

delete is apparently a keyword in ActionScript (the word shows up blue in Flex Builder) and cannot be used as a function name even if the function is in a CFC.

I changed the function name in the CFC to deleteRecord and ProgramDAO.deleteRecord( aProgramObj ) works fine.

After checking the Programming ActionScript 3.0 documentation I found delete on the keywords list on page 75. When you do use the delete keyword as I tried to above you get a hard-to-understand error message. It took me a while to figure out the cause of the problem, so I'm posting this blog entry to hopefully help others avoid my mistake.

Comments
This was brought up during public beta, but I'm unsure why the change wasn't finalized. deleteById() might show up in the next release, though.
# Posted By James Lyon | 11/15/06 2:51 PM
There is another way of calling a function on the remote object which should get around the problem:

myRemoteObject.getOperation('nameOfCFCmethod').send(arg1,arg2,...);
# Posted By mh23 | 7/17/07 1:13 AM
Or just spell delete with an upper case "D".

myRemoteObject.Delete();

That should work.
# Posted By Joe | 10/11/07 8:13 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.