Library assets not compiling when publishing for AIR - actionscript-3

Yesterday I started messing around with Adobe Scout. It gave me a message that said that my function times are not accurate because I'm running a debug mode (in a file that is compiling as an AIR app) and to try compiling a published version first. Thus began my foray into the exciting world of AIR certificates and Windows Installer packages. I made certificate, published it, opened the published package, installed it, opened the resulting file, and found... fanfare ... a rectangle object I draw with AS3 and nothing else. When I test the movie (debug version) in AIR, it has the rectangle as well as a 20x20 map of tiles that are created at runtime from a bitmap that is blitted into 16x16 tiles.
Huh? Do I need to do something special when publishing for AIR to embed the library item? Anyone have this issue publishing to AIR where library assets are unavailable at runtime?
Of course I'll post code if anyone thinks they would like to see it, but it all works fine in flash player, fine (albeit slow) in Adobe AIR for Desktop (when testing), just missing library assets when published and installed via Windows installer.
update
for that matter, when I publish a swf for playback on the web or flash player, a similar thing: just a colored background (per my .fla file settings) but no rectangle and no blitted bmp tiles. Could I be executing code before something is loaded, and when it is in a debug mode, the setup takes longer, so things have time to get loaded before trying to execute? I've tried to avoid this, but maybe failed?

So, apparently making an .exe file or AIR app doesn't stand alone from the library components. Their is probably a way to embed them in the project, but for my purposes, I found that just making sure that the .exe and necessary .png files are in the same source file solved the issue. The problem was that my .exe file was automatically getting compiled and saved into a different folder, so I thought that folder must have all the needed files in it.
So, the bottom line is just that an .exe or AIR file, when published, won't automatically have the needed files in the right places. It still needs to point to the correct file location for those files.

Related

How to use Haxe SWF for Compiled Adobe Air Desktop App

How can I convert a Haxe SWF to a compiled native app using AIR?
Is there a way to override the Flash default .SWF export when you use a Haxe Command Line to export a SWF that can be packaged up into an Adobe Air file?
I'm having trouble finding information on how to compile a Haxe .SWF export via command line into Adobe Air. Ive tried deleting the default swf and renaming the Haxe .swf export, but Adobe still rewrites it when it packages everything up.
E.G: "haxe -swf main-flash.swf -main Main -swf-version 15 -swf-header 960:640:60:f68712"
I'm using Mac OS X with Flash CC and Atom to write my game with Starling-HAXE. I want to target desktop (PC/MAC/Linux).
Thanks!
The OpenFL tools used to support Adobe AIR on the desktop, if you look at this older helper class, you may find hints on how you might go from a Haxe-generated SWF file to a final AIR application:
https://github.com/openfl/lime-tools/blob/master/helpers/AIRHelper.hx
Looking at it again, I believe you call ADT with the proper signing parameters. You probably need an application.xml file as well, here is one:
https://github.com/openfl/openfl/blob/master/templates/flash/templates/air/application.xml
You would need to replace variables such as "::APP_PACKAGE::" with com.yourcompany.yourproject, and other sensible values.
If someone would like to look at integrating AIR support into the Lime tools again, I'm open to the idea. The problem I was concerned about was long-term maintenance
I have some batch files that will do this (although will most likely need to be reworked on your behalf). I'm not at my computer right now, but will post them over the weekend. On a side note it would be great to have this type of functionality baked into flashdevelop.

Converting SWFs to EXEs

I'm building a program in Actionscript 3 and would like to convert the .SWF file to an EXE without using Flash Pro CS5. I found http://swf-to-exe.com/ and it works well, but I'm wondering if there is another way to do this. In the long run we'll need Mac executables, too, and if I can avoid putting it all in Flash I'd like to do that.
The most simple way is to create projector file with Flash Player, but you have to do it for every OS. It embed the hole Flash Player into the resulting *.exe file.
Steps for exe:
Download 11.2.202.235 Flash Player vesrion
Open flashplayer_11_sa_32bit.exe
Open swf file with this FP or drag and drop swf on player
File->create projector
As I know the last FP version, where projector feature works is 11.2.202.235, for Mac it can be another version. There is the description of this #Bug 3363321 in Adobe bugbase
Adobe AIR is the standard solution for packaging SWF applications natively. The AIR SDK is freely available and includes the mxmlc compiler which will compile .as to .swf, and the adt packager will package your SWF and assets for Android, iOS, Windows, and OSX.
It looks like you want to bundle natively for Windows to produce an executable. Do you have a programming environment? You may want to check out the free Flash Develop IDE.
Ah, so you are using Flash Develop... Good, onward.
In Flash Develop, I created an "AIR AS3 Projector" type project named DesktopTest. I then modified the Packager.bat file according to the article I posted above. Change the OUTPUT and call adt lines and leave the other lines of the file in-tact:
set OUTPUT=-target bundle %AIR_NAME%
And:
call adt -package %OPTIONS% %SIGNING_OPTIONS% %OUTPUT% %APP_XML% %FILE_OR_DIR%
You then need to run CreateCertificate.bat once (right-click, execute). After that, compile your project and run PackageApp.bat. For my project named DesktopTest, this results in a DesktopTest sub directory that is my compiled app, with a DesktopTest.exe in it.
SWF converted to EXE is most likely a projector file, it still needs a Flash Player. Depending on build it could have the FP compiled into itself and thus don't need a Flash Player externally, but it comes with a cost or larger file-size.
Now with AIR, you have a choice to make a Flash project that will run natively trough the AIR virtual machine (that can be included for compilation time, so the user doesn't need to install it separately). But still, there WILL be a SWF file in that EXE or APP package.
Good thing about AIR - it works universally on both Win and Mac. Mobile platforms are also supported.
You can build AIR projects without buying Flash Professional, CC or Flash Builder. Just download the SDK and compile your code.
If you're using Windows, you can do it very easily with FlashDevelop - it's a powerful IDE that works out of the box. And it's free too!
http://www.flashdevelop.org
Get MDM Zinc. It has everything you need for crossplatform flash development.

cocos2dx and some kind of image cache

I am playing around with cocos2dx in Xcode and developing for iphone. My question concerns the creation of sprites from png images stored in the Resources folder. Images load and everything works good until I remove, say, mysprite.png from the Resources folder. cocos2d should give me some kind of error like file not found but it compiles well! And even loads mysprite.png somehow. It seems like the sprite I removed is still stored somewhere in some kind of cache. If one such cache exists, how can I clear that cache?
This is not because of cache. When Xcode compiles a project and creates an app bundle, it copies all the resources in the directory (which results in addition of all new resources and replacement of all the modified ones in that bundle but doesn't delete the resources that have been removed).
You can remove app from Simulator or your iPhone so that next time when the app is installed, the newly built app won't have resources that have been removed.

How to set Flash Player window location in Flash project as3?

I have 2 monitors on my computer, also am writing a program on AS3 that is exported to standalone SWF. My task is to make my app fullscreen on 2nd screen. How can I do this?
I tried converting my project to AIR project. It is possible there by using nativeWindow property of Stage. (setting x coordinate so that it appears in second screen and then call fullscreen). It works in Flash, but when I'm running compiled swf outside Flash, my app crashes (nativeWindow property not found).
So please do help me to solve my problem. I am disappointed, have been looking for solution for already 3 days...
You have to stick with your AIR application and use it as it is supposed to: run the .air file. You can't launch an AIR swf alone because it will miss all the AIR runtime including the NativeWindow you are insterested in.
To be clear, you can't manipulate windows from a swf launched with the Flash Player.
Another solution would be to execute your swf from a web browser and use javascript called through ExternalInterface to move the windows. But it may be quite painful in comparison with AIR.

Best way to make a downloadable version of a Flash game?

I already made a game with flash, and I want to provide an easy download for people that would rather play offline. Thing is, i use a folder whole structure to dynamically load content per level. Folder structure looks like this, not that it matters that much:
Game folder
animations
anim1.swf
anim2.swf
sounds
music1.mp3
soundeffect1.mp3
levels
level1.lev
level2.lev
myGame.swf
How should I go to distribute this? Should I just resort to make a zip file for the flash game and assume people know how to extract and open the swf? Is there any other way to port easily as an executable? Perhaps Adobe Air (not sure if this works though)?
Thanks, and please help!
Distributing a zip file is the only option if you really want that structure to prevail. Else,
Embed all the resources in the main (myGame) swf & distribute it.
Provide a html page for people who do not have standalone flash player installed.
Embedding as a single file allows the browser to cache the single swf & allow the player to keep playing offline until cache is cleared. So user might not even need an explicit download.
If you are using Flash Builder it is fairly straightforward to compile the application into a self-installing AIR executable (or DMG on a Mac). It is possible to include the AIR runtime which would avoid potential problems of the user not having the correct flash player for example.
An alternative to AIR would be to create a projector executable from inside the standalone Flash Player or from the Flash authoring environment.
Another option to using a zip file would be to use a free installer creator such as InnoSetup or Nullsoft on Windows, or Packager on Mac. Linux users are generally more tech savvy and so a tar would probably be well understood.
Adobe AIR works wonderfully! I use it for my own project, and your project should transition over to it with little to no modification (any issues should show up in the Compiler Errors and Output). The only downside is that, past AIR 2, there isn't any Linux support.
The other option is obviously to create a standalone .SWF projector inside a zip or installer, but in my opinion, that isn't the sleekest way to deploy for desktop. The advantage of AIR over this is that it gives you access to additional desktop functions that Flash Player doesn't.