How to generate a hard crash on Adobe AIR - actionscript-3

I want to add bugsplat reporting to my Adobe Air app, this part of the code is done and working.
However, for QA purposes I need an easy way to crash (hard crash, not only cause an exception) the application so the bugsplat window will come up.
Most of my attempts end up in Air throwing an exception, not forcing the application to close.
Any ideas?

Related

VS2012 doesn't break on exceptions for new project

I added a new console application project to my VS2012 solution.
When it encounters an exception, I get an error dialog, and VS2012 does not break and go to the source line that threw the exception.
The original project that was created together with the Solution does break on exceptions properly, so I think the issue is that the newly created executable is not marked as relevant for breaking on exceptions. (The debugger is "not attached"? I'm not sure if this is the right term)
How can I make VS2012 start breaking on exception in a project?
I am using the Debug configuration, the pdb is being generated.
There is an issue with recent x64 Windows systems when they do not propagate exception properly back to the x64 application when function calls cross kernel boundaries.
There are plenty of posts here on SO and all over the internet about it, for example the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64
You can fight it to some extent by going to Debug->Exceptions and flagging CLR exceptions Thrown column. But note that then VS would break even on the exceptions handled by you.

How to detect Flash runtime errors?

I'm developing an AS3 application with the commandline tools from the Flex SDK. My workflow is:
write code
compile with mxmlc
run the SWF file in favorite webbrowser
repeat
The second step catches compile-time errors, but what about run-time errors and warnings? And trace() output? How can I see that?
I'm not using any IDE with debugging capabilities.
Get the debug version of the Flash player and Firebug for Firefox, then you can see the traces and errors in the console.
When a run-time error occurs that isn't caught by an exception handler you will get a popup telling you about the error.
Why not get http://www.flashdevelop.org/? It's free and it has debugging, profiling and all other goodies you can expect from an IDE.
Although the Flash debugger is a pretty good choice. I would personally suggest Monster Debugger. It is a great debugger with a very intuitive user interface and it has a plethora of features that make debugging extremely easy.
Flash player debugger writes the output of trace() to the flashlog.txt file. Its location is hardcoded and is different on different systems. On Linux it is in ~/.macromedia/Flash_Player/Logs/flashlog.txt. In order to have The debugger to actually write into that file, you need yet another file, mm.cfg, it's location and name are again hardcoded. It should be in ~/mm.cfg. It may contain many different options, but the one you are interested in is ErrorReportingEnable=1.
You may then $ tail -f ~/.macromedia/Flash_Player/Logs/flashlog.txt to see the progress as the file is been written to.
Note that the directory and the file must be writable by the user running the player. Flash player will not issue any warnings if that is not the case, and will fail silently.
Also note that if you are happened to be on Linux, then there isn't a 64-bit version of a debugger player... However, the player runs fairly well under Wine, the Windows version that is.
You may debug using commandline debugger found in SDK. it's called fdb (fdb.exe or in Apache Flex fdb.bat on Windows). It has similar to gdb interface, can do breakpoints, some runtime code evaluation, disassemble functions, look up stack frames and their variables and most of the other stuff you'd expect a debugger to do. I'm usually running it from Emacs, but I would imagine that running it from Vi[m] or whatever editor you are using shouldn't be a problem...
If you were using Emacs, it is actually possible to hook up Flymake to a part of the SDK that does syntax checking while you type. You can find more info on how to do that here: http://www.flashdevelop.org/community/viewtopic.php?f=13&t=9238 (thanks Philippe).

Debugging with the projector AS3 Flash projector

I'm working on a Flash game that runs fine when testing through Flash professional, but once it's exported to a projector, it won't run on either PC or Mac.
I've got a PC (Windows 7) and it basically closes the window with a white screen as soon as the projector opens. FWIW, it used to work on a projector until recently when I implemented some new functionality including stage web view, DesktopFacebook API integration etc.
How do I debug this problem with the projector? Has anyone run into issues like this before?
you can use Monster Debugger
it should be able to solve your problem
You can use Vizzy. It will give you access to all traces and error messages (no code changes required). Or, as AyoubKaanich suggests, you may use a proper debugger.
You must install the projector in debug version first.
Thanks for the responses. It actually turned out that Flash was looking for the StageWebView class which isn't available to the standalone projector-- it compiled and ran fine in Flash Pro because I had it set up to test as an Air Desktop app. When I built the projector it didn't throw a compile error at publish time but just refused to load after.
I ended up diagnosing this problem by running the SWF in the debugger projector, which I probably should have just done from the beginning...

Direct all errors to a textfield

I am developing a Flash game. It has a complex loading scheme which could go wrong at many different places.
When I am testing from Authoring Tool, either with "Test Movie" or "Debug Movie", it always succeeds and starts fine.
However, every time I test it by loading it in a browser, it always fails! I am not sure where to look.
The question is this : is there an easy way to direct all internal errors to a TextField on Stage where I can really check what went wrong? Alternatively, is there any other way to catch and show errors when testing on a browser?
Debug player is a must. It allows you use breakpoints and view your application state (like values of variables and so on) at runtime (if you are using an IDE with a debugger, like Flash Builder ofc). Viewing traces in console window is quite annoying, though, so you can use some external debug utility, for example Monster Debugger. It has some nice features, like highlighting MovieClips (and other DisplayObjects) at runtime.
You can use UncaughtErrorEvent to intercept all internal uncaught errors of a swf through a method.
The best way is to install the debug flash player. There is no way that I know of to direct internal errors anywhere. Apparently there is, see other answer. It's still probably easier to install the debug player however.
You can get the debug player from http://www.adobe.com/support/flashplayer/downloads.html (scroll down a bit).
As for the error itself, there are two common reasons:
If the files are hosted elsewhere, you need a crossdomain file set up
The base url of the flash file is not where you think it is, and thus any relative paths fail to resolve correctly.

AS3 Embedding assets - "Warning: Failed to parse corrupt data"

I've got an AS3 project where I'm trying to compile in several images, a soundtrack, and a video via [Embed] metadata. It's a product requirement that these be embedded, so network transfer is not an option.
I'm getting some really strange behavior - a sort of intermittent corruption of the compiled-in data. Sometimes after the project compiles, I run the swf and it closes immediately and writes "Warning: Failed to parse corrupt data" to the flash log. If I delete the binary and clean the project, sometimes it'll run fine after building it again. Sometimes it doesn't.
This is probably the strangest part about this problem, but sometimes when I see that error, I can physically move the video [Embed] lines to the end of the file, then clean the project, and it will build and run no problem. Sometimes I move them back to the beginning of the file and it builds and runs fine.
It kinda seems like it might be a bug in the compiler. Has anyone else experienced something similar? I'm targeting Flash 10.1 and using sprout (http://projectsprouts.org) to build my project. This is the mxmlc line that's being used to compile (mxmlc Version 4.1.0 build 16076):
mxmlc -as3 -static-link-runtime-shared-libraries=true -debug -default-background-color=#ffffff -default-size 712 400 -output=bin/ProjectName.swf -source-path+=.preprocessed/src -source-path+=.preprocessed/assets .preprocessed/src/ProjectName.as
I've tried both removing the -debug compiler option and adding the -optimize option, but no luck.
Everything is being ran through the GNU C preprocessor for some other tasks, so maybe I'll try removing the preprocessor stuff and hardcoding those variables...I'll try that and post the results tomorrow.
Any insight at all would be much appreciated. Thanks!
EDIT:
This project is going to be compiled dynamically with different assets being embedded into the same codebase, so switching to something like Flash Builder for compilation really isn't an option...it must be done via command-line mxmlc.
UPDATE:
Turns out the corrupted data message was due to images created with Photoshop's "Save for web" feature. If I save them outright as PNG images I don't get the message. However, the intermittent nature of the movie compiling properly still seems to be an issue. Now sometimes when the project is compiled it won't throw any compiler errors, but I get a blank flash player window. Right clicking in flash player shows a context menu with a message that says "Movie not loaded..." This doesn't appear to have anything to do with things being ran through CPP first.
[Screenshot]
This is apparently a bug in mxmlc under Mac OS X. After posting this, I observed some other really strange behavior, so I switched the whole codebase to Windows 7. Everything works as expected there (still using Project Sprouts as a build tool).
Flash builder is fine with it.
Can you separate your issue for video or music only, or issue is true for both includes?