tags:

views:

71

answers:

1

I have an MXML component that includes a .as file with

<fx:Script source="myfile.as" />

Running asdoc throws a whole bunch of errors like

"Error: The private attribute may be used only on class property definitions."
"Error: The public attribute can only be used inside a package."

The only useful information I could find on the subject was in this article: http://danielmclaren.net/2009/08/28/using-asdoc-with-mxml-files-and-included-scripts.
The problem is described there with two possible solutions:

  • Solution 1 is to move the AS code into the MXML file. Kind of defeats the objective of using external .as files for MXML components in the first place, so really a last resort option. Code inside a mxml file is messy (I really don't want logic mixed in with mxml), and would also require using the < !--- ---> asdoc syntax.
  • Solution 2 is to have the MXML component inherit from a normal class file. That would mean no private members in the base class, only internal (meaning a separate package for the component to be safe) or protected. This would make things tedious to say the least.

Are there any other work-arounds or possibly a beta/nightly version of asdoc that fixes the problem? I am using the Flex 4.1.0.16076 SDK, the "latest production quality release".

Update

Just tried using asdoc from the svn trunk, (4.5.0 rev. 16942) and the problem persists.

A: 

Honestly, I got used to Solution 1 and never looked back. I figure I'm already mixing AS and MXML, so where's the harm? Plus you get the added advantage of being able to have the member highlighting bridge both AS and MXML. Click on the text of the id property of your HBox, for example, and your code window gets markers that show you where on the page that member is referenced. This is a nice feature that is, for me, well worth abandoning any fussiness about separating AS from MXML.

Robusto
The markers are quite possibly a useful feature, but I see the mixing of logic with UI layout and presentation code as a messy mashup. Adobe added the option for a reason: "If your project involves significant ActionScript code, the best way to organize your code is in separate ActionScript source files"; http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fd6.html My objective and subjective conclusion is to split into MXML components into .mxml and .as files.
Alan G.
@Alan G.: The point is, you *are* mixing up logic and presentation as soon as you start using MXML and ActionScript in the same component anyway. Putting the two in separate files just makes it harder to work with, IMO.
Robusto