1
votes

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:

1
I had trouble with compiling a worker swf with File usage and never figured it out. If you figure it out, please post your answer here. :)Aaron Beall

1 Answers

1
votes

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