Interactive ActionScript interpreter? - actionscript-3

Is there some sort of interactive ActionScript interpreter? Similar to Firebug's JavaScript command line or Python's interactive shell?

Try AS3Eval Library - it is AS3 compiler implemented in AS3. It has simple interactive shell.

There's also Frontal:
http://code.google.com/p/frontal/
It has an ActionScript interpreter built into it. It's based on the ECMA 2.62 (JavaScript) standard so it's not full AS3 and doesn't support things like packages and classes but it's still extremely handy.
As I mentioned, the interpreter is part of a larger library implementing the Frontal language but if you were so inclined you could pretty easily just rip out the interpreter.
Or you could just use it in Frontal. And if you did then you do get a console that allows you to run ActionScript in a primitive shell. For example, go to the Frontal website. (I can't post the link because my reputation is low but it's frontalcode + com.) Right-click and choose "View Frontal Source..." This will open the Frontal console. At the bottom of the console, click "command line." This is your "shell."
Try something like this say:
5 + 4 * 10
or
movie.alpha = 0.5

Actionscript is a compiled language and the compiled byte code is executed by the Flash Player Virtual Machine. There are a number of tools out there that will create Actionscript byte code based on Actionscript source code. I'm not aware of the existance of any tools that will intrepet AS byte code and execute it other than Adobe Flash Player.
Although I do not say it's not possible, I haven't seen nor heard of any tools that gives you an interactive shell for Actionscript.

flash-console project does exactly that. They have a demo and an online help.
Special commands start by a slash like /help
Variables can be stored and accessed via $some_name
/ changes current scope to the last returned value.
The project is meant to be integrated in your project.

Related

Is there any way to run two instances of flash professional debug

After already searching the site for the answer to the question, I've found this:
Is it any way to run two instances of debuggers?
I need the Flash Professional CS5.5 version of the answer to this question.
Basically - I need to know if there's a way to debug 2 different .fla files in Adobe Flash Professional CS5.5 at the same time. One of them implements the Adobe AIR framework (for using the SocketServer class), the other is a standard AS3 project. It'd be nice if I could debug the client-server interaction easily using the IDE rather than using extensive means to do so.
Anyone have any ideas? Thanks.
This is not an answer to your question but a suggestion to take a different approach.
The Flash IDE and it's debugger are inadequate but for most trivial programs. Variable inspection and breakpoints work randomly and it's next to impossible to drill down into more complex objects. Flash IDE is all right for creating the visual resources for Flash programs but for any serious coding, it just falls on its face. The compiler included with the Flash IDE is also very poorly written and generates unoptimized code.
I'd suggest to switch over to using FlashDevelop - it's a free, open source IDE that runs on top of the Flex and Air SDKs and uses a better compiler that performs more optimizations. (You can mark functions for inlining, etc.) The debugger - while not Visual Studio - is much, much better than the IDE: breakpoints work and object properties can be inspected easily.
Because FlashDevelop is geared towards coding, you can create a project in it with multiple source files, define your resources and then compile to multiple platforms. Compilation is usually fast with hundreds of source files (don't import every type in every package) and you can do debug/release builds. If you can port your code from Flash to FlashDevelop, you'll have a much easier time managing your project.

Standalone actionscript interpreter?

I want to to play around with Actionscript, mostly to compare the language with Javascript (I'm interested in the type system). Is there a straightforward way to do that or do I need to also install Flash or something similar? I'd prefer something that works on Linux but Windows-only is fine too.
Basically, I want to know if there is something for Actionscript that is analogous to v8/NodeJS or Rhino for Javascript, where you can run JS scripts directly (using console.log for output) without having to use a browser, create an HTML page, etc.
There is an amazing online tool capable of compiling Actionscript 3.0, this will aid your investigation of the language!
http://wonderfl.net/
As3Eval also is a good tool. Play around with the demo to get a feel for it.
It's windows only, but download Java, then install FlashDevelop : http://www.flashdevelop.org/
It'll download the flex sdk and everything you'll need to get started.
You'll need flash player to see your tests, and normally the debug player (take the standalone), which you can download here: http://www.adobe.com/support/flash player/downloads.html
As #neil says, you can also use wonderfl to test directly online, though obviously the experience won't be the same as a full ide.
You should be able to develop on Linux directly if you want to install flash builder (eclipse) but it's not free

How to use library of other languages in Action Script 3?

Is there any way to use the library of other language in Action Script 3 ?
For C/C++
I learned that we can use Alchemy: http://labs.adobe.com/technologies/alchemy/
But for other languages (here I mean Ruby or Java), can I use their libs via AS3 ?
Alchemy is a cross-compiler from LLVM to ABC, if the language you are interested in can compile to LLVM, then, in theory, you can compile to ABC. So, Alchemy supports (with some tweaks) also C# or Java (but you will have to spend some time getting them to work together, there's no out of the box solution).
AIR (which is a desktop variant of Flash) can use something called "NativeProcess" which means that granted the operating system can execute the code in the library, then you can do so by creating a new process that calls the function from the library you need.
In AIR, again, there's a new feature called ANE (AIR Native Extensions) - this allows you to bind AIR more tightly to the native code. But, it doesn't need to be native as in object files only, it should be something the underlying system can execute. But I have to confess, I never tried creating any such extension, so my knowledge of it is theoretical.
No you can not use Ruby or Java code/libraries in Flash. Alchemy only allows you to use C and C++ libraries. The only way is to port those libraries to ActionScript, or maybe the library you want to use has already been ported to AS3.
It is also possible that there is something similar in AS3. You could ask another question here or on an Flash forum if anyone knows if the library you need has an equivalent in flash.

ActionScript 3 as a console app?

Is it possible to have actionscript 3 as a console app? I want to play around with the language and do basic things like hello world and inheritances or file IO if thats allowed. Is there a REPL or a compiler (that will allow me to write a console app) for actionscript 3?
If you're serious about command line as3 you should have a look at redtamarin, based off the Mozilla Tamarin project:
http://code.google.com/p/redtamarin/
Though I think the complexity of building the tools might defeat the purpose of a "hello world" situation? Depends if you're looking for proper command line tools or just experimentation.

Flash Pro CS5 - expected function parameters and syntax error highlighting

I'm working with actionscript in Flash Professional CS5, and I find it very slow and difficult because of the following three issues:
No way to know what kind of parameters a function needs. When you hover over a function in Visual Studio for instance, it tells you what parameters it takes and what it returns. Same with variables, shows you the type. This makes things go a lot smoother, especially when you're working with other people's libraries or you're just using a flash function for the first time. Right now, I have to publish and see the error message in order to know what parameter types were expected by that certain function. (am I missing something here?)
No variable/function highlighting. In other environments, when you select a variable, all instances of that variable, including the definition, are highlighted throughout the document (like in notepad++). This is not hugely important, but again, makes life easier.
And finally, live syntax error highlighting. Y U no have that, Flash Pro? There's that blue checkmark button that says "Check Syntax", but it never seems to do anything, even when there clearly are "asdfsdg"s in the document.
Is it possible to actually get any of these features in flash pro or do I just have to suck it up and write things notepad-style? I'm also working with Stage3D and FP11, so I can't debug any more and I have to publish every time, which makes everything even slower.
Thanks for any insight on this.
PS: I know about Ctrl+Space
Use Flash Builder to edit ActionScript.
Extending Eclipse, it is a superior code editing environment. It will encapsulate similar functionality as you'd find in Visual Studio with ReSharper.
Flash Builder may be used standalone to compile pure ActionScript projects; or integration with Flash Pro is seamless. You may right-click a symbol with AS linkage in Flash Pro and select "Edit Class" choosing "Flash Builder" as the editor.
Syntax lighting, intellisense / auto-completion, navigating classes, searching keywords, refactoring, auto code generation, override implement methods, indentation, auto formatting, organizing imports, ASDoc - all features you would expect from an IDE are provided by Flash Builder.
As well, Flash Builder includes extensive debugging and profiling functionality far beyond Flash Professional.