Use IntelliJ Idea to Debug ActionScript Running in a Browser? - actionscript-3

I have an ActionScript project that runs inside of another swf (embedded on an HTML page) so I can't use the 'Debug' option in IntelliJ's menu. Is there a way to connect the IDE's debugger to the browser so I can use breakpoints and such?

You can use the Flash Remote Debug option, just create a new remote debug profile
then hit debug and intelliJ waits until a swf debug file is launched on your computer it can be with a standalone player or plugin in a browser. both of them need to be debugger versions and your swf needs also to allow debugging (in Flash CC default does not accept debugging you need to change the publish settings).
I use this method to debug with IntelliJ an swf launched inside Flash CC hitting cmd+enter.
Maybe it works when you load and swf inside another.

Related

How to compile actionscript worker swf in FlashDevelop

I already know the coding part of actionscript worker. Recently I switched my IDE to FlashDevelop. I can't figure out how to compile actionscript worker swf in FlashDevelop.
I try to use Tools - Flash Tools - Build current file. But it throws error saying
Error: Type was not found or was not a compile-time constant: File.
Maybe it is because my project is a AIR project and I use AIR API in my worker.
I also try to compile worker swf using amxmlc via command line. It compiles successfully. But AIR Debug Launcher crashes when executing worker swf part. The swf which I compiled manually is nearly half size of the former one that Flash Builder generated for me. I guess I compiled a release version swf so that ADL can't debug and then crashed.
So how do I compile a worker swf in FlashDevelop to debug or to publish a release of project?
Update:
I find that the "Build current file" command in menu is a feature in FlashDevelop called quick build. By default, it will compile current file output to project root directory without arguments. We can add compiler arguments using #mxmlc ASDoc tag (see the links below for detail) to make it compile a worker swf for us. But currently in FD 5.0.1 it seems to be a bug that #mxmlc +configname=air doesn't compile air swfs. I find a workaround using #mxmlc -noplay -library-path=[Flex_SDK]\frameworks\libs\air\airglobal.swc -library-path=[Flex_SDK]\frameworks\libs\air\airframework.swc, but the path can't be surrounded with quote otherwise FD will show an error. I may look into the source and try to fix it.
links:
AS3 Quick Build documentation
Quick Build
FlashDevelop: Compiling Multiple SWF In One Project
Compiling a worker is no different from compiling any swf, you will need a separate project to compile the worker, unless your main worker loads itself as a worker.
Since FlashDevelop does not manage dependencies beetween projects, you will have to compile it manually, then the main worker.
You may automate it with make or any build system outside FlashDevelop, or use Pre/Post build command lines
By the way amxmlc is just a shortcut for 'mxmlc +configname=air', -debug=true will compile debug version
I can assure you that File can be used in a worker, basically it's just some actionscript bytecode loading some other actionscript bytecode and having it run in a separate thread, so any swf can be used as a worker, except if it doesn't use flash.system.Worker class, it won't be able to communicate with other workers, or to stop itself.
To sum up, the limitations and issues are rather about communicating beetween threads and synchronizing them. For instance, being able to only copy complex objects through AMF3 serialization,pass only basic types/objects as parameters will makes it impossible to interact with the display list from non-main workers
Dont forget to update FlashDevelop /AIR SDK for best workers support

Flash Builder debugger error : Flash builder failed to connect to running application

I am trying a simple code for event handling. I applied break point on a line of action script code of event. I want to see the debug window to check which event is generated. It does not show me any error but whenever i click the debug button i get the following problem
The Flash Builder debugger failed to connect to the running application.
Ensure that:
For in-browser applications, you are running the debugger version of Flash Player.
For network debugging on a mobile device, you have a reliable network connection to the device, and port 7935 is open on your machine's firewall.
My project runs correctly in browser showing the desired output but it shows me launching failed dialog with above error. Please help
One other thing you can try which worked for me when the above didn't - in Flex Compiler in Properties for the project, untick Generate HTML wrapper file, apply that, then tick it again and apply again. Seems to clean/reset the project in some way, which 'clean project' doesn't.
Try to shutdown "adl.exe" in taskmanager, It seens the old adl.exe occupied port 7935 that flashplayer can't creat new one.
That's how I solved it.
It happens many a time, but you can solve it in 4 ways
1) Clean the project and try.
2) Close flex builder and reopen it. try it, If that doesn't work than go for 3 option
3) Change your workspace and import that project in it or best is create new one and make the changes in it, Sometimes the workspace get corrupted and so it happens...
4) If above 3 option that doesn't work than reinstall your Flex builder, make sure that you uninstall flex builder properly.
I had exactly that symptom. Blank browser window, a freeze at 57% for 2 minutes and the same error message.
The problem was an error in my javascript. As usual, it just silently aborts whatever it is doing. As a result, the SWF was never started and the debugger failed to connect to the running program.
So, if the browser window remains blank it is probably a javascript error. Display the javascript console to see what is going on.
When I faced this issue what I had to do is re-install the adobe flash debugger version for firefox and Flash could successfully run in debug mode
Reason for the error : The firefox updates the flash builder version which for some reason doesn't work with the Adobe Flash Builder 4.6
You can follow below steps and get the flash application run in the debugger mode :
1) Go to https://www.adobe.com/support/flashplayer/debug_downloads.html
2) Download : [Download the Flash Player content debugger for Firefox - NPAPI][1]
3) Install the downloaded executable and install it over whatever version of Adobe Flash
builder that you have .
4) Restart the Flash Builder and run the application in debugger mode and check if it
works.

SWF is not a loadable module when compiling from flash builder 4.6 but not 4.0

Having a very strange issue on an inherited project. The developer who built the project (using fb 4.0 and flex 3.0.0.477) is able to compile it and the application works just fine, both locally and on the server. However, if I take the identical code and compile it using fb 4.6 and the same flex sdk, the application works locally, but starts failing to load modules on the server, giving a "SWF is not a loadable module" error. There are no other errors from the debug sessions.
All crossdomain policy files appear to be in place. The module even begins loading, but receives the error after 5 - 10% downloaded.
I also tried setting the application domain using modLoader.applicationDomain = ApplicationDomain.currentDomain;, with no results.
Thanks!
So after long hours of troubleshooting, it turns out that the main application widget was being loaded over https, while the modules were being referenced at http. I guess flash builder 4.6 enforces stricter security settings. I now reference both the widget and the modules at https, and the application is working again.
Thanks, Shaun, for the help!

Flash Builder Mac Breakpoints generate NullPointerExceptions

I have a complex, pre-existing Actionscript project to work with at my current employer. The project was originally created with FlashDevelop, which is not an option for me as a Mac user. I can successfully build the project and deploy it to others. It runs as expected.
The problem is with the debugging. I cannot make it work. I believe users of Flash Builder on Windows machines have successfully debugged this project on their machine. I can build and debug projects I make myself. It's THIS particular project, or something about how it is constructed, that is preventing debugging from occurring.
Symptoms:
Starting the program via the Debug button runs the program, but the presence of a breakpoint causes the program to freeze the browser where it is running
Removing the breakpoint or stopping the debugger allows the browser to unfreeze and continue normally
At no point does the breakpoint actually get reached and break into the debugger
Attempting to place a breakpoint during execution results in an internal error: java.lang.NullPointerException
Example log message from within .metadata/.log
java.lang.NullPointerException
!STACK 0
!MESSAGE Error processing debugger commands
!ENTRY com.adobe.flexbuilder.project 4 43 2011-08-24 13:35:07.404
at java.lang.Thread.run(Thread.java:680)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.run(FlexDebugTarget.java:793)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.eventLoop(FlexDebugTarget.java:732)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread$1.run(FlexDebugTarget.java:752)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.access$7(FlexDebugTarget.java:642)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.advanceStateMachine(FlexDebugTarget.java:668)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.installDeferredBreakpoints(FlexDebugTarget.java:637)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget.access$4(FlexDebugTarget.java:1006)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget.instantiateBreakpoint(FlexDebugTarget.java:1012)
at com.adobe.flexbuilder.debug.breakpoints.FlexLineBreakpoint.instantiate(FlexLineBreakpoint.java:465)
at com.adobe.flexbuilder.debug.breakpoints.FlexLineBreakpoint.findSourceFiles(FlexLineBreakpoint.java:412)
Attempted Fixes:
Cleaned project
Cleared browser cache
Tried different browsers (Yes, I have the debug player)
Deleted .metadata
Deleted workspace
Reinstalled Flash Builder
Reinstalled Debug Flash Player
Restarted Mac
Tried a different SDK
Reordered Java preference for both 32 and 64 bit configurations
Removed symlinks from project configuration (that is, symlinks are no longer needed to correctly find the build or run location)
Cleared Flash logs
Ensured no more than one version of the program was getting compiled (so it can't actually be running from another location)
Explicitly turned on debugging through compiler argument: -debug=true
Changing just about every relevant and lots of irrelevant settings within Project Properties
Project Details:
Interestingly, clicking on Actionscript Applications in the Project Properties results in Flash Builder immediately becoming unresponsive
Uses third-party libraries for functionality that may or may not be Debug builds
Uses third-party code for functionality that is included with the rest of the code via Actionscript Build Path > Source path (note that this folder must be included explicitly for this project even though the path included is already in the source directory)
Runs from a local web server, accessing local database using a custom domain that is not "localhost" nor an IP address (changed for Chrome cookie issues), rather it looks like http://programname.local/
Launch configuration starts the web browser at the correct local url (as opposed to starting up from a file), probably irrelevant
There is one additional compiler argument that simply creates a global, compile-time constant, probably irrelevant
Source and project directories contain svn repository folders and files, probably irrelevant
I have an NDA, so I can only talk about the project and its structure, I can't post code
Configuration:
Mac OS 10.6.8
Flash Builder 4 (through CS5)
Flex SDK 4.0 and 4.5.1
Figured it out. Our app uses a preloader which I had always gotten from others. I had assumed it was compiled to debug because I always got my copy from our debug server. I didn't fully understand how it worked or what it was doing.
Due to a Flash error in the preloader, this morning I was forced to compile it for the first time. Compiling it normally (as debug) I realized the problem with non-debug swfs loading debug swfs might apply here.
Breakpoints worked as expected once I correctly compiled the preloader and fixed its bug. Apparently our preloader is doing the actual loading of the main app. Flash Builder apparently can't handle this setup (non-debug loading a debug swf), whereas FlashDevelop apparently can.
Have you tried restarting your Mac?
I feel your pain, and your list of attempted fixes are what I'd try first :)
I had a similar situation to this and after hours of cursing Adobe I restarted my Mac and that solved it (probably some kind of memory error).

Intellij IDEA - Actionscript Project - Cannot connect Debugger version of Flash Player

I installed flash player debugger and cannot able to debug the flash application.
And I got following message in console.
Waiting for Player to connect
Failed to connect; session timed out.
Ensure that:
1. you compiled your Flash movie with debugging on, and
2. you are running the Debugger version of the Flash Player.
Dont know how to fix.
If you are using chrome, the default flash player is not the debug version. After installing the Debug version of the player. you must disable the default version in Chrome.
Open Chrome
Go to chrome://plugins
here you should see both versions of the shockwave player. Disable the first one or the one that is located here:
C:\Users\your_username\AppData\Local\Google\Chrome\Application\22.0.1229.94\PepperFlash\pepflashplayer.dll
Now the debug version should be working in Chrome and should also work from Intellij if chrome is your default browser or set as the browser to open on debug.
Browser
Don't use Chrome to debug your SWF as it contains a non-debugger version of Flash Player. So after installing the Flash Player debugger, use Firefox, for example and make it as default browser.
SWF File
Be sure that you compiled your file as a debug version. To do that, have a look to your project structure. Then on your module and build configuration. In the compiler options, you should be able to check the "Generate debuggable SWF" option.
RUN/DEBUG Configuration
Check in the What to launch option, you selected your swf via HTML Wrapper. Check also that you selected the right Flex SDK in the options panel:
FINALLY
Launch your debug configuration. Intellij will build your project, create an HTML wrapper and launch it in the default browser (Firefox).
Your SWF should then be debuggable. If it still does not connect to the debugger in Intellij, right click in your flash application in Firefox and click Debugger
Based on the suggestion given by Timofei & bmleite, I fixed it.
When you debug pure SWF, make sure to check the default player is a debug player. Debug player has "Show Redraw Region" on right click.
IDEA generates html file that embeds swf file for users' convenience. If you open this html from file system, it allows you to debug SWF. If you put it (with the rest of files) to http server, then 'Debug' menu item is disabled in Chrome. In IE it works fine. This is obviously a Flash Player's bug.