testingactionscript-3

ActionScript: Questions about writing/compiling a block of code without a class or function?


  1. Having done some programming in Groovy, I know you can write test code in the Groovy console. I classify this as true a scripting language as it doesn't force you to have a class definition.

  2. So I'd assume with a name like ActionScript with 'script' in it's name that, you can write a series of statements that act linearly, such as a sequence of variables assignments, their manipulation and dumping out a value.

    My question is if this is possible, how do you go about doing it, in order to test some code with ActionScript3?

  3. Does the code have to exist in a package?

  4. Can the code exist on it's own? (If so, what would the name be you'd give to the source file in order to compile it from the command line?

    • Would you use mxmlc?

    • Would you use compc?

    • I've heard about fsch too. How about that?

    • I also read about a command called 'asc' in R.Braunstein's AS3 Bible 2nd ed (P8), but don't even see this in the SDK bin folders.... So what's that all about?

    • Assuming I've managed to compile this name.as file, how do I execute it and see results? Do I have to run it through a browser and the HTML template, or can I execute from a command line?

  5. Do you have to have a class in the source to bypass this?

  6. Can the code block be placed outside a dummy class?

  7. If so, does it have to exist in a function?

  8. Or can it exist on it's own?

  9. Does it have to exist in a code blocks, by wrapping them in curly braces?


Solution

  • Overall, ActionScript is not so true script language as you might like. It is dynamic, but compiled and not really meant for interpretation.