Adobe Air android with 2 swfs questions

I created c:\sdk and put inside the AIR32 sdk, so now is c:\sdk\AIR32

I also put c:\sdk\AIR32\bin into PATH system variables.

So now I am guessing:

Do I remove the Main.as as document class and then I compile the swf in animate cc? That will have as result an empty stage, but behind the scenes will be all the assets and the code, except the Main.as
Then I suppose, I use the command line and somehow I include the Main.as and the Preloader.as

Am I at the right track? Or I’ll use the fla file directly into command line? In that case you should know that I include some swc files.

Thank you for your time!

yeah and please take it as a soft guideline, nothing prevent you to change the organisations of stuff later on as you see fit, but let’s just say it will make things easier for a start

so Windows 10, good, 64bit, even better

in general it is good to not use a too old OS for the build of your app
and something sometimes “not obvious” is that most tools in general
but in particular the Adobe SDK etc. support only to build from a 64bit OS

that’s because if you need to build both 32bit and 64bit, you can only do that from a 64bit OS

so for that, if Windows is your OS of choice I would advise either a
Windows 8.1 Pro 64-bit (at the minimum) or Windows 10 Pro 64-bit (ideally)

so first thing to do is to install Java, simply because all the SDK tools depends on Java
you could get away with a Java JRE (only install runtimes) but I would advise to install a JDK (install runtimes and Java SDK)

Go there
https://www.oracle.com/technetwork/java/javase/downloads/index.html

and select a recent JDK for Windows 64-bit
but it does not really have to be the bleeding latest version
as the Adobe SDK tools need minimum JDK 1.6

in the current choices you have

anyone would work but technically you could use Java SE 8u20x

so in term of versioning: Java SE v8" means “JDK v1.8” (few years ago they changed the way how they version Java)

in fact, if you have doubt about such things (what version of something to install) check out the wikipedia page, so here https://en.wikipedia.org/wiki/Java_(programming_language)
or here https://en.wikipedia.org/wiki/Java_version_history

it should make clearer what is what


For the command-line itself, Windows kind of always had a “bad command-line”
and so by default you will have access to the Windows command prompt

but there is also another one: the Windows PowerShell
(easy to differentiates the two because PowerShell use a blue background by default)

they are all command shells

simply put a text interface to your computer: you write commands (the standard input) and it output results as text in general (the standard output), and sometimes with some errors the output is considered an error stream (the standard error).

every command shells use its own language, sometimes it can be very similar but it depends

here under Windows, every valid command for CMD.exe is also valid for the PowerShell
for ex: ver

C:\> ver

Microsoft Windows [Version 6.3.9600]

C:\>

this part C:\> is called the command prompt

with PowerShell you will see a “PS” PS C:\>

with other operating system you might see something with a $ for a normal user
or a # for a root user (a kind of super user or administrator)

The very basic to know, please don’t let that discourage you

  • a command shell allow you to input commands that you usually write by hand
    those commands can be either internal to the shell or can be external commands
    that in fact depends on a command-line executable
    • the command echo is internal to the CMD shell (eg. it does not depend on an external echo.exe)
    • the command java (to execute Java) will depends on an external executable named java.exe
  • a command shell find those external executables based on an environment variable usually named PATH
    • do read about environment variable
    • do read about PATH
    • under Windows to know what is inside this variable just type C:\> echo %PATH%
      you will see a list of paths separated by a ;
    • for now the only thing you need to check is to be sure to have the path to the Java executables in your PATH, after you install a Java SDK (you might need to reboot or restart the command shell)
    • so instead of typing C:\> C:\ProgramData\Oracle\Java\javapath\java.exe (the full path)
      you will just have to type C:\> java.exe
    • read about some commands here https://ss64.com/nt/cmd.html
      and here https://ss64.com/nt/syntax-cmd.html
  • a command shell, in general, allow to be scripted and under Windows you can write Batch scripts with the extension .bat
    • those scripts allow you to use a basic programming language
      so you can write a series of commands into a file, maybe use a couple of variables, and run it as if it was a real executable (but that I mean a binary)
    • so yes at the beginning using the command-line will be slower if you type everything by hand
  • but once you get you can write little scripts to repeat and automate this and that it becomes blazing fast eg. C:\> compile_stuff.bat "my_project"

I know it is a lot of stuff but it is a learning process. got step by step, get used to it, explore the different options available to you (I will go more in details with that) and jsut do the basic like “navigating the file system”, “learning the basic commands of the current shell”, “write little scripts”, etc.

so under Windows 10, here all the options available to you

  • just use the CMD.exe and write .bat scripts
    it is kind of limited but it will be compatible with almost any Windows
    from Windows XP to Windows 10

  • use the PowerShell and learn its own scripting language also named PowerShell
    this is much more advanced and maybe too big to chew when you get started
    see the PowerShell Documentation

  • use a UNIX-like shell under Windows and write scripts in Bash (to not confuse with Batch)
    or also write scripts in almost any other programming languages that can work on the command-line: Perl, Python, PHP, Ruby, etc.

    under Windows it requires a special setup but then it gives you the big advantages to share those scripts (running under Bash) with other OS like macOS and Linux (but technically you can also run PowerShell scripts under macOS and Linux)

    • you can use a Virtual Machine (let’s avoid that for now)
    • you can use Windows Subsystem for Linux or WSL
      in short it install a distribution of Linux like Ubuntu inside your Windows 10
      and give you access to a bash.exe or a wsl.exe that put you into a Bash command shell that is running under Linux but that can still access your Windows file system
      see Windows Subsystem for Linux Documentation
    • you can use Cygwin
      even a default basic install for Windows 64-bit will give you a new commmand shell: MinTTY

      so instead of starting the command prompt (CMD.exe) you start MinTTY and this one directly put you into a Bash shell by running bash.exe and your prompt change to C:\> to $ because now your shell behave like a UNIX-like shell
    • and few more options but let’s stop here for now

Here the logic behind all that, different command shells give you different “super power”, some are easier to automate and program with scripts than others, or could be simply that you will find more examples or scripts to get inspired from, or tutorials etc.

As a beginner into the command-line world I perfectly understand that all those options can be confusing and you start to wonder “wow …is it really worth it to learn all that crap?”

So let review our core goals here

  • to be able to do more advanced stuff you do need it to run on the command-line
    it is how it is, 99% of programming language and tools and SDK go through the command-line
  • wether it is X or Y shell, stick to one shell at the beginning and stick to one scripting language
  • the only goal of knowing those (shell and scripts) is so you can write little program that automate tasks for you but without spending weeks doing so
  • those “little programs” will allow you to perfectly control what is build or not and in which orders
    so yeah you might spend a couple of days writing such script but then by reusing it every day you work on your program you avoid going through a GUI and you save a lot of time (on top of gaining control of what’s going on)
  • the end goal is to have an automated build that not only you can use for this project
    but that you can configure and adapt for other projects in parallel or later

Here classically I guide you towards building such “automated build” using something called Ant

The Flex and AIR SDK being developed in Java they are already setup to use Ant (which also use Java) in some ways, to make it work you just need Java to be installed, some SDK to be installed and write a build.xml file to build your project

to “run the build”, whatever choice of command shell you make you will either need to do something like

C:\> ant.exe

or

C:\> ant.exe -f build.xml

(I oversimplify but that’s the idea)

or

$ ant

or

$ ant -f build.xml

etc.

Here an example of build on one of my “old” projects

this build is driven by some configuration files with the .properties extension
for ex

another ex is

this part

FLEX_HOME_MAC = /sdk/flex/4_6
FLEX_HOME_WIN = c:/sdk/flex/4_6

local.flashplayerversion = 11
local.swfversion = 13

is how you get in control of which SDK is used for the compilation
which flash player version is used etc.

the cherry on the cake is that it will work under Windows and macOS, and it could also work the same under Linux

If you work with someone else, you can just give him or her access to your sources
tell which dependencies they need on their system
(you need Java this version, Flex SDK this version, etc.)

and they can run the build on their machine and obtain the same results you get on yours

And yes, “as is” it may seem overkill, especially if you are alone working on your project,
but in the long run, even for 1 dev, such build helps tremendously, not only to be able to do advanced things but for cases where you work on different projects, publish for different targets etc.

that time you spend learning those thing make you a 1 dev army :slight_smile:

Ultimately by knowing how the tools work at this level of detail you gain confidence and you become less afraid to do more :stuck_out_tongue:

If today you’re building only 1 app for only 1 platform Android
tomorrow you will be able to manage many more just by yourself

but step by step, you don’t need to know everything in one day, give yourself the time to explore and learn what is best for you

1 Like

yes that’s one way to do it, and for you now it is perfectly valid

all the executables under the c:\sdk\AIR32\bin folder
are now available to you directly by their name instead of their full path

for ex

C:\> mxmlc --help advanced

side note, later you might want to do slightly differently if you are in the case where you want ot use in parallel c:\sdk\AIR32\bin, c:\sdk\AIR33\bin, c:\sdk\AIR34\bin etc.

that depends

usually if all your code is only .as files
if before you were compiling your app from within Animate CC
then after you can compile your code by using the SDK compilers on the command-line

if your .fla contains assets or symbols you are reusing in your code
you need to “split” the compilation

for example you could

  • compile from the .fla file a component .swc
    for ex: myassets.swc
  • then with the command-line build tell the compiler
    that your source code is depending on that external SWC
  • form within your .as sources you can then reference that
    external asset by its exported symbol name

in the FLA, in your Library
export Symbol foobar as mypath.assets.Foobar
with a base class of MovieClip or Sprite

that generates myassets.swc

in your main.as class for ex

import mypath.assets.Foobar;

//...

var mc1:MovieClip = new Foobar() as MovieClip;

and you compile it this way

C:\> amxmlc -library-path lib-swc/myassets.swc src/main.as

you just tell the compiler that you re using a SWC as a library to reuse in your code
amxmlc will generate a SWC file and then you can launch it with adl

C:\> adl myapp-app.xml

with the file myapp-app.xml referring to myapp.swf (the SWF you just build with amxmlc before)

Now two things

  • you can build it “by hand” writing all the commands on the command-line
    but soon it will get old, so what you want is to use a script or a build tool
    so you can repeat those commands without entering everything yourself
  • using assets compiled from a FLA is mainly useful if your assets are Library Symbols
    you “build by hand” like some timeline animation etc.
    if you just need to reuse “static” assets like sound, images, etc.
    most of those can be embedded directly with your source code

for ex:

 |_ src
       |_ myapp
             |_ ui
                 |_ icons
                      |_ air.png
                      |_ air.as
package myapp.ui.icons
{
    import flash.display.Bitmap;
    
    [Embed(source="air.png")]
    public class air extends Bitmap
    {
        public function air()
        {
            super();
        }
    }
}

and then you use it

import myapp.ui.icons.*;

var air_bmp:Bitmap = new air() as Bitmap;
//...
something.addChild( air_bmp );

this way, using the metadata [Embed(source="something.ext")]
you can embed .png, .jpg, .svg, .mp3, etc.

see: https://github.com/as3lang/ActionScript3/wiki/Embed

yes, just do it step by step
maybe use a basic project “displaying a blue rectangle” to test stuff around

and when you get to the point “ah ok you reuse SWC like this” etc.
then you apply that to your current project

I would say from there, look into Java and Apache Ant (mentioned in another post here)

here few links to follow

start simple, take the time to learn Ant, find examples on Github etc.
eg. https://github.com/search?q=mxmlc+build.xml&type=Code

or try to build existing project from sources, for ex

could be anything else

1 Like

Thank you very much!!!

I see you put a lot of effort to help me, so I’ll try my best to make as good use of your effort as possible!

Now it is time to study! Thank you once again!!!

I updated the special thanks section. I credited this community and personally @zwetan, as I promised.

Now I going back to study the command line. If I succeed, the next update will be with preloader.

1 Like

wow … that super nice, thank you :blush:

you don’t have to mention me by name, just pointing to as3lang is more than enough

let me know if you need different logo formats

some were published here

but I need to updates them with new stuff

just sayin’ … if you need a nicer logo in vector format and with transparency just let me know

1 Like

Thank you for the AS3 logo links. I will use a vector one at next update. Also If you want to remove your name or change it to just Zwetan, tell me, otherwise I will leave it as it is now.

About my studies of the command line:

I started as simple as possible. Learning unix like or PS command line feels overwhelming. So I am trying to understand the basics with the simpler cdm

So far I managed a succesfull build with the following steps:

a) first I compiled my project inside Animate CC to build an swc file that includes my whole project, except the Preloader.as

This is the command line I managed to figure out so far…

amxmlc scr/Preloader.as -library-path swc/xromatopaixnidia.swc -external-library-path+=[ANE1 here] -external-library-path+=[ANE2 here etc] -frame=0, Preloader -frame=1,Main -swf-version=43

I get some warnings from greensock library, I suppose it’s ok, and I get a Preloader.swf

b) I rename my Preloader.swf to xromatopaixnidia.swf to match my xromatopaixnidia-app.xml file. I know that xromatopaixnidia-app.xml is working fine because I compile my project in Animate CC with it.

c̶)̶ ̶T̶h̶i̶s̶ ̶i̶s̶ ̶t̶h̶e̶ ̶s̶t̶e̶p̶ ̶t̶h̶a̶t̶ ̶I̶ ̶a̶m̶ ̶s̶t̶u̶c̶k̶.̶ ̶ ̶I̶ ̶m̶a̶n̶a̶g̶e̶d̶ ̶t̶o̶ ̶f̶i̶g̶u̶r̶e̶ ̶o̶u̶t̶ ̶t̶h̶e̶ ̶f̶o̶l̶l̶o̶w̶i̶n̶g̶ ̶c̶o̶m̶m̶a̶n̶d̶ ̶l̶i̶n̶e̶.̶.̶.̶ ̶>̶a̶d̶t̶ ̶-̶p̶a̶c̶k̶a̶g̶e̶ ̶-̶t̶a̶r̶g̶e̶t̶ ̶a̶p̶k̶ ̶-̶s̶t̶o̶r̶e̶t̶y̶p̶e̶ ̶p̶k̶c̶s̶1̶2̶ ̶-̶k̶e̶y̶s̶t̶o̶r̶e̶ ̶p̶i̶c̶o̶u̶p̶i̶c̶o̶u̶-̶c̶o̶l̶o̶r̶g̶a̶m̶e̶-̶s̶s̶l̶.̶p̶1̶2̶ ̶ ̶x̶r̶o̶m̶a̶t̶o̶p̶a̶i̶x̶n̶i̶d̶i̶a̶-̶a̶p̶p̶.̶x̶m̶l̶ ̶x̶r̶o̶m̶a̶t̶o̶p̶a̶i̶x̶n̶i̶d̶i̶a̶.̶s̶w̶f̶ ̶ ̶T̶h̶a̶t̶ ̶l̶i̶n̶e̶ ̶p̶r̶o̶m̶p̶t̶ ̶m̶e̶ ̶t̶o̶ ̶t̶y̶p̶e̶ ̶t̶h̶e̶ ̶k̶e̶y̶s̶t̶o̶r̶e̶ ̶p̶a̶s̶s̶w̶o̶r̶d̶ ̶a̶n̶d̶ ̶t̶h̶e̶n̶ ̶I̶ ̶g̶e̶t̶ ̶t̶h̶e̶ ̶f̶o̶l̶l̶o̶w̶i̶n̶g̶ ̶e̶r̶r̶o̶r̶:̶ ̶ ̶>̶ ̶F̶i̶l̶e̶ ̶x̶r̶o̶m̶a̶t̶o̶p̶a̶i̶x̶n̶i̶d̶i̶a̶-̶a̶p̶p̶.̶x̶m̶l̶ ̶i̶s̶ ̶n̶o̶t̶ ̶a̶ ̶v̶a̶l̶i̶d̶ ̶A̶I̶R̶I̶ ̶o̶r̶ ̶A̶I̶R̶ ̶f̶i̶l̶e̶ ̶ ̶ ̶*̶*̶H̶o̶w̶ ̶c̶a̶n̶ ̶I̶ ̶b̶u̶i̶l̶d̶ ̶a̶ ̶v̶a̶l̶i̶d̶ ̶A̶I̶R̶I̶ ̶o̶r̶ ̶A̶I̶R̶ ̶f̶i̶l̶e̶?̶*̶*̶ ̶ ̶I̶f̶ ̶y̶o̶u̶ ̶h̶e̶l̶p̶ ̶m̶e̶ ̶f̶i̶g̶u̶r̶e̶ ̶o̶u̶t̶ ̶t̶h̶a̶t̶,̶ ̶I̶ ̶s̶u̶p̶p̶o̶s̶e̶ ̶m̶y̶ ̶n̶e̶x̶t̶ ̶s̶t̶e̶p̶ ̶i̶s̶ ̶t̶o̶ ̶f̶i̶g̶u̶r̶e̶ ̶o̶u̶t̶ ̶h̶o̶w̶ ̶t̶o̶ ̶p̶u̶t̶ ̶t̶h̶e̶ ̶A̶N̶E̶s̶ ̶i̶n̶t̶o̶ ̶a̶d̶t̶ ̶c̶o̶m̶m̶a̶n̶d̶ ̶l̶i̶n̶e̶.̶ ̶

c) I figured out how to create an airi file and to include ANEs in it. Command line:

adt -prepare airi xromatopaixnidia-app.xml . -extdir …/libs-ane

d) Finally, package time!

adt -package -target apk-captive-runtime -storetype pkcs12 -keystore picoupicou-colorgame-ssl.p12 xromatopaixnidia.airi xromatopaixnidia-app.xml xromatopaixnidia.swf -extdir …/libs-ane

I had errors about missing the icons. I removed the icons reference from -app.xml file. I will figure it out later.
I got xromatopaixnidia.airi with almost double size

e) I renamed the xromatopaixnidia.airi to xromatopaixnidia.apk
I installed the apk into a real device and got wrong screen dimensions. I fixed that easily with [SWF(backgroundColor="#000000", width=“480”, height=“800”, frameRate=“30”)] above Main class…

…and at last I finaly managed to compile and pack into apk BUT…

Now the app is very slooooow with terrible frame rate. Also the loading times did not seem to improve and I did not see any splash screen :frowning:

I suppose I barely have half the job done… So I will try again tomorrow…

Please tell me if you see what I did wrong…

TODO:
-fix perfomance
-fix preloader
-figure out how to include the icons
-figure out how to set the output name of swf correctly so I will not rename it manually

Thank you for your time!

OK so like that I think you’re doing OK but doing a bit too much together

so let’s fix little things this and there

first, good structure of the files and folders

try to have something like that

projectname
    |_ bin-release
    |_ bin-debug
    |_ build
    |   |_ ...
    |
    |_ lib
    |   |_ ...
    |
    |_ src
        |_ ...

projectname is what we call the “root” of the project
and so when you work from the command-line try to work from that folder

other directories

  • src is your source folder, where you put your .as files etc.
  • lib is your libraries folder, where you put .swc files
  • build is where you put files for your build
    (the things that build your project but are not part of your project)
  • bin-debug is where you build the “debug” project
    if you generate a debug .swf it will be generated there
    for ex: if you work with Flash Builder it will put the files there
  • bin-release is where you build the “release” (usually non-debug) of your project
    that’s where you will generate .swf files, .air files, etc.

because you use ANE you might want to distinguish your lib folders
lib-ane for the .ane files
lib for the .swc files

or another case if you had at the same external sources, SWC and ANE
lib-ane for the .ane files
lib-swc for the .swc files
lib for the .as source files (considered external to your project)

for example, if the project name is “xromatopaixnidia”
you could be in a directory structure
C:\work\xromatopaixnidia> for the project

eg.

C:\>
  |_ work
      |_ xromatopaixnidia
      |_ project2
      |_ project3
      |_ etc.

and so you should working from the root of that folder

C:\work\xromatopaixnidia> COMMANDS

that’s what we call the “execution context” or your “pivot point” related to the command-line
when you are IN that directory you know where to access what with relative paths to that “root”


second, use Ant

in the root directory of your project you create few files
for ex:

xromatopaixnidia
    |_ bin-release
    |_ bin-debug
    |_ build
    |_ lib
    |_ src
    |_ README.md
    |_ build.xml

here we are interested in build.xml, that’s your Ant build

the goal is to always run the short command

C:\work\xromatopaixnidia> ant.exe

from the same root directory

and so “Ant” will by default look for build.xml

and inside the build file “build.xml”
you will be able to refer to other build files from the build/ folder
refer to the sources of the project from src/
etc.

to get there you need to install Apache Ant
https://ant.apache.org/

download it from https://ant.apache.org/bindownload.cgi
under " Current Release of Ant"
you will get either a .zip file or a .tar.gz file or a .tar.bz2 file

to install manually, take the .zip file, unzip it into your program files
get it’s full path, and then add an environment variable to be able to access it later

for ex, with a Java JDK " Java SE 8u202"
should be installed there C:\Program Files\Java\jdk1.8.0_202\

and with an Apache Ant " apache-ant-1.9.14-bin.zip"
should be unzipped/installed there C:\Program Files\Java\apache-ant-1.9.14\

in your environment variables
you define

JAVA_HOME with the value C:\Program Files\Java\jdk1.8.0_202\
ANT_HOME with the value C:\Program Files\Java\apache-ant-1.9.14\

and the you modify the PATH so it contains the value
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin;%ANT_HOME%\bin

eg. you had to your PATH: %JAVA_HOME%\bin and %ANT_HOME%\bin

see Add to the PATH on Windows 10

once all that is setup, from your root folder run ant

C:\work\xromatopaixnidia> ant.exe

output should be

Buildfile: build.xml does not exist!
Build failed

so create the file “build.xml” and try again

C:\work\xromatopaixnidia> ant.exe

output should be

Buildfile: C:\work\xromatopaixnidia\build.xml

BUILD FAILED
C:\work\xromatopaixnidia\build.xml:1: Premature end of file.

Total time: 0 seconds

and that’s normal, now write a very basic build

<?xml version="1.0" encoding="UTF-8"?>
<project name="xromatopaixnidia" default="main" basedir=".">
    <target name="main">
        <echo message="hello world" />
        <echo>project name = ${ant.project.name}</echo>
    </target>
</project>

output should be

Buildfile: C:\work\xromatopaixnidia\build.xml

main:
     [echo] hello world
     [echo] project name = xromatopaixnidia

BUILD SUCCESSFUL
Total time: 0 seconds

now with that basic stuff go read the Ant manual and learn the basic

if Ant or Java is not setup correctly, the manual will have infos about that

do absolutely read “Using Apache Ant” and follow the
Writing a Simple Buildfile tutorial

from that point, write your build.xml

  • detect if the folder bin-release exists, if not create it

  • in a “compile task” translate your command-line

    amxmlc scr/Preloader.as -library-path swc/xromatopaixnidia.swc -external-library-path+=[ANE1 here] -external-library-path+=[ANE2 here etc] -frame=0, Preloader -frame=1,Main -swf-version=43

    to use the task Exec see List of Tasks

    • learn to define variables
      for ex: <property name="swf_version" value="43"/>
    • learn to use variables, for ex replace things like scr/Preloader.as with ${src}/Preloader.as
      or do something like -swf-version=${swf_version}
    • learn to define variables into an external .properties file
      and load that file into your ant build

also for the performance and preloader stuff
set that aside for now, just learn to compile your project from the Main class without the preloader
we will add that later

2 Likes

ok good but don’t burn that step

in general you will find lots of tutorial to learn the UNIX-like command-line
but less the Windows command-line

here few links

Computer Hope How to use the Windows command line (DOS)

Bleeping Computer Introduction to the Windows Command Prompt

Princeton University Windows Command Prompt in 15 Minutes

Microsoft Docs Windows Commands
gives you a list of all console commands built in and their documentation

for ex for ver

1 Like

I DID IT!!! I managed to build with ANT!
I found an example build.xml and with help of ant manual and trial and error, I changed and added what I figured to be necessary.

Buildfile: D:\Projects\air\xromatopaixnidia_ANT\build.xml

clean:
[delete] Deleting directory D:\Projects\air\xromatopaixnidia_ANT\deploy
[mkdir] Created dir: D:\Projects\air\xromatopaixnidia_ANT\deploy

copy:
[copy] Copying 1 file to D:\Projects\air\xromatopaixnidia_ANT\deploy
[copy] Copying 1 file to D:\Projects\air\xromatopaixnidia_ANT\deploy
[copy] Copying 1 file to D:\Projects\air\xromatopaixnidia_ANT\lib

build:
[exec] Loading configuration: C:\Program Files\Adobe\Adobe Animate CC 2018\AIR32.0\frameworks\air-config.xml
[exec]
[exec] 10813688 bytes written to D:\Projects\air\xromatopaixnidia_ANT\deploy\xromatopaixnidia.swf in 7,623 seconds

airi:
[exec] Warning: Using default implementation for native extension ‘com.myflashlab.air.extensions.dependency.overrideAir’

package-release:
[exec] NOTE: The application has been packaged with a captive runtime.

release:

BUILD SUCCESSFUL
Total time: 44 seconds

OK back to work now…

TODO:
-fix perfomance
-fix preloader
-figure out how to include the icons

1 Like

good stuff :slight_smile:

sorry if I was a bit too pushy to use Ant
but really you will see with time it help a lot

now Ant like anything else, you can do simple things and more advanced things

so try to make it work for you

for ex: you could add a variable to your build

C:\work\xromatopaixnidia> ant.exe -Dsomething=true

and that would not only build the SWF, the AIR app etc.
but then it would launch the app with ADL, or launch it with an emulator, etc.

keep at it, it will get better and easier with time

is it more or less same that when you were building with Animate CC or is it much slower?

this is basically organising which is built in which order and use the good seqeucnes or arguments for the compiler

probably just a path issue

so now that you have a build, and if those problems above persists, now you can share the build here (using triple backtick and indicating xml)

  ```xml
  <xml> stuff </xml>
  ```_ <- not the underscore

it should show as

<xml> stuff </xml>

Well, the game is pure vector based, with very heavy shape tweens, and I have the framerate of stage at 30fps. I managed to keep the frame rate average at 27fps when I build with Animate cc. Building with ant now is very slow something like 4-5fps. I deactivated the Event.DEACTIVATE, Event.ACTIVATE, just in case, but again same 4-5fps…

NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, appDeactivate);
NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, appActivate);

I will post again this afternoon with details about the preloader and the other issues…

where and how to you test this “frame rate average at 27fps” ?

it is a release build or a debug build?

do you test on the desktop or on a mobile device?

does the test that gives “something like 4-5fps” is happening in the same conditions?

ideally if you could put the screenshots of the UI settings you have for compiling with Animate CC
and the XML of the Ant build, I could compare if “some things” are missing in the Ant build

I am using Hi-ReS-Stats to check frame rate.

I am using the -target apk-captive-runtime argument on adt, so I suppose it is considered as release. For a debug build the correct argument is -target apk-debug, am I correct?

Because of the ANEs I prefer to test on mobile device

After some testings I conclude that the very low frame rate is happening only when I use
the arguments -frame=0,Preloader -frame=1,Main at amxmlc

I also tried the variations:
-frames.frame=0,Preloader -frames.frame=1,Main
-frames.frame+=0,Preloader -frames.frame+=1,Main
-frames.frame+=1,Preloader -frames.frame+=2,Main
-frames.frame+=one,Preloader -frames.frame+=two,Main

but without any success. I even added the argument -default-frame-rate=30 just in case…

But if I remove completely the -frame arguments, then the ant build is as good as is the build from animate cc. I can say the ant is maybe 2 times faster to complete the build that animate cc.

Sure! here is xromatopaixnidia-app.xml I use for Animate CC build
and here is the xromatopaixnidia-app.xml I use for the ant build! The differences are, that I removed the icons temporarily and changed to the appropriate path at line 33 ().

Here is a screenshot with animate cc air settings

and actionscript settings

and finally here is ant’s build.xml

Thank you for your time, and tell me if you need more info

EDIT: I forgot to upload the publish settings screenshot

so just to be clear

xromatopaixnidia.swc is your app sources you compiled from Animate CC
but that you’re re-using compiling the app with Ant right ?

so my guess at what’s happening is

  • you compile the target ${src.dir}/Preloader.as
  • with the lib -library-path ${lib.dir}/${swc.file}
    which is all your source code pre-compiled
  • so when it come to frames it does not work
    because you use pre-compiled sources instead of actually compiling the sources

so let review the compiler stuff

you do not want to use -library-path ${lib.dir}/${swc.file}
for your main source code, even if it can work somehow, it is prone to errors and complications

each time you compile your app you do want to compile it from sources (not from pre-compiled sources aka a SWC)
and for that you need 2 things

  • a main class
    for ex: ${src.dir}/Main.as
  • a source path
    eg. -source-path ${src.dir}

now about compiling you need to understand also how linking works

when you compile against a library you have two choices

  • compile against and link the library
    that means the final binary contains your code and the library code merged into it
  • compile against but omit to link the library
    your code will compile without error because it knows about a dependency
    but the final binary will contain only your code, not the library code

when you use -external-library-path according to the doc

-compiler.external-library-path [path-element] [...]
    alias -external-library-path
    list of SWC files or directories to compile against but to omit from
    linking (repeatable)

so best example is airglobal.swc
you want to compile against it but not embed its code in your final output
because its code is already embedded in the AIR runtime
for that one you would use -external-library-path

another example would be a “normal” SWC library
like starling.swc, uanalytics.swc, etc.
those are basically AS3 sources pre-compiled into a SWC
so for those you want to use -library-path
eg. you want to merge their code into your final output

now when it comes to ANE

  • when you compile the SWF you use -external-library-path
    so your source compile against the ANE library but without embedding it
  • and only when you compile the Android app with ADT
    there you embed the ANE library

so this part

    <target name="build" description="Compiles the project SWF">
        <exec executable="${air.amxmlc}" failonerror="true">
            <arg line="${src.dir}/Preloader.as"/>
            <arg line="-library-path ${lib.dir}/${swc.file}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane1}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane2}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane3}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane4}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane5}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane6}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane7}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane8}"/>
            <arg line="-external-library-path+=${ane.dir}/${ane9}"/>
            <arg line="-frames.frame+=1,Preloader"/>
            <arg line="-frames.frame+=2,Main"/>
            <arg line="-default-frame-rate=30"/>
            <arg line="-swf-version=43"/>
            <arg line="-output ${deploy.dir}/${swf.file}"/>
        </exec>
    </target>

change it to something like that

    <target name="build" description="Compiles the project SWF">
        <exec executable="${air.amxmlc}" failonerror="true">
            <arg line="-output ${deploy.dir}/${swf.file}"/>
            <arg line="-strict=true"/>
            <arg line="-warnings=true"/>
            <arg line="-optimize=true"/>
            <arg line="-swf-version=43"/>
            <arg line="-target-player=32"/>
            <arg line="-debug=false"/>
            <arg line="-verbose-stacktraces=false"/>
            <arg line="-default-frame-rate=30"/>
            <arg line="${src.dir}/Main.as"/>
            <arg line="-source-path ${src.dir}"/>
            <arg line="-external-library-path+=${ane.dir}/"/>
        </exec>
    </target>

the arguments -strict, -warnings, -optimize
configure the compiler

-swf-version and -target-player let you control the AIR API version

-debug and -verbose-stacktraces
is what will produce a debug build or a release build
if both are true you ll produce a debug SWF and so get a debug build
if both are false you ll produce a release SWF and so get a release build

you don’t need to add each ANE individually with -external-library-path
just indicate the directory containing all the ANE

and only once you got that working, then you will go into using the -frames option

I will explain briefly how my project is constructed.

The project is a game for preschool children and help them in a fun way to learn the colors. Is only in Greek language for now.

Project spine:

  • Mini games, ui and parents section are pre-compiled into individual swcs.
  • Minigames has dependencies from ui.swc, the code of ui.swc is not merged into each minigame
  • finally I was building the project in animate cc from a fla file that contains Main.as, main menu, settings, choose mini game menu. That fla file has in actionscript settings all the swcs and anes. From that fla file I was building the final apk.

Every symbol that I wanted interaction is a movie clip. Various graphical elements like eyes, mouths, teeths etc are graphic symbols attached to movieclips. Every movieclip is exported at frame 1, and has a Class .as attached to it, except if shares common logic with other movieclips so it has base Class.

Now with ant, I understood (maybe mistakenly) that I need my project precompiled in a big swc, and then I compile with preloader using ant.

Now to my questions
Should I put all swcs seperatly into final build with ant, using -external-library-path?
Do I remove Main.as as document class to create the xromatopaixnidia.swc (the one the connects everything) and the I compile with ant with Main.as class? If yes, how will I implement the preloader.as?
Maybe should I rename source folders and compile swc files without source? I thing the animate will put emty classes in that case…

EDIT: I saw you removed the line completely

<arg line="-library-path ${lib.dir}/${swc.file}"/>

did you wanted to be replaced to something like this?

<arg line="-external-library-path+=${lib.dir}"/>

PS. I learnt already so many things in a few days. Thank you!

yeah maybe we should have started there

well … at first look it seems you’re building a mobile app as if it was like an online SWF

I get you use a lots of SWC, but I don’t really see what you gain by doing that

I would say at this point you build everything around a specific design or way of doing
and it’s too late to remodel everything into something else

so yeah … whatever the design, good or bad, you are kind of stuck with it now
I guess you don’t to restart from scratch, so you gonna have to accept the limitations of the design

I’ll few comments, but bare in mind from how it is structured it’s not jsut adding a couple arguments on the command-line that can change a lot

In the general idea of a SWF file, a stream of bytes, you can use -frames to spread the load of your codes / dependencies / assets / etc. over multiple frames

from this

         |*|
frames:   1
          |
          all the code and assets here

to that

         |*|*|*|*|*|*|
frames:   1 2 3 4 5 6
          | | | | | |
          | | | | | main app code
          | | | | etc.
          | | | etc.
          | | assets
          | fonts
          preloader only

Except, there are big parts of your code that are pre-compiled into SWC

and this conflict totally with how the compiler can spread different part of the code over different frames

-frames.frame [label] [classname] [...]
    alias -frame
    A SWF frame label with a sequence of classnames that will be linked
    onto the frame. (advanced, repeatable)

at compile time if you tell the compiler
-frame N classname
it knows on which frame to compile it, but for this to works it needs to be at compile time

if it is already compiled into a SWC, from the top of my head I don’t think it will work

And now the “design” is

so with that, if you need to modify a game, that is assets or code, you basically have to recompile it from Animate CC, so it is not in the logic of compiling it all from the command-line

that part “Minigames has dependencies from ui.swc” is more problematic
if ui.swc change then you do have to recompile all the minigames depending on it, and again you need to go through Animate CC

it works for you but it put you in a position where compiling the main app from the command-line or Animate CC does not change much

that other part

again force you in a particular corner

you see, it’s one thing + a second thing + a third thing + etc. it is a “design”

if I was to tell you now: well no you do this and that instead, you will have to restructure everything
it is a bit counter-productive

so I would say “stop”, deal with what you have and go with it
and well if the problem is you can not have a splash screen because the design of how the thing is built force you in a particular corner, well … let’s call it a limitation of the design

I’m not saying it is hopeless, but you are at the end of a cycle, not a the beginning of a new one
so end the cycle with what you have and try to keep it as sane as possible

on a later update or “version 2”, there you can break everything apart and start fresh with a new design (I’m talking about code and how code is organised).

this “break things apart” not gonna take just few days, it’s not impossible but
you already have something working, almost done, I think it is better to just finish it
even if the small features (like a splash screen) can not be done.

My advice so far would be to “forget” about the command-line for now

  • consider your current project as “version 1”
    keep doing what you do with Animate CC, a lot of mini games pre-compiled as SWC etc.
    maybe some workaround can be found for splash screen or whatnot, but keep it together
  • in parallel, for later, start to build a “version 2”
    where you reorganise things differently and where you build everything from the command-line
    in short you will break up apart what you have in “version 1” and use a “different” design or organisation for that “version 2”, just be aware that it will take some time

Use that “version 2” to test things, for ex: “how would I got at building minigames 1 and having a dependency on UI without pre-compiling SWC and building it all in one go from the command-line?”

The exercise is to understand and control how things connect.

The command-line can allow to do more and maybe more efficiently but it is not magic, there is no silver bullet, so take the time to master it.

that’s very hard to say right now, “as is” all those SWC: UI, mini game 1, mini game 2, etc.
are not part of the build, so because they are SWC build from Animate CC I think they are exported on frame 1 by default.

Another design would be to

  • only export an assets.swc from Animate CC
    this one containing your symbols “Various graphical elements like eyes, mouths, teeths etc”
  • but build the mini game from source code .as file and compile them during the build
    not pre-compile them as SWC
  • and there you could use the -frames

eg. frame1.as

package
{
    // for a reference to the assets so there are embedded in this class
    import com.foobar.assets.eyes; eyes;
    import com.foobar.assets.mouths; mouths;
    import com.foobar.assets.teeths; teeths;
    //etc.

    public class frame1
    {

    }
}

and at compilation time -frames 1 frame1
will make the compiler embed the bytecode of the class frame1 exactly on frame 1

it is the same logic as this how to force compiler compile all classes in my project?

package
{
public class IncludeClasses
{
    import com.abc.db.Database;Database;
    import com.abc.logs.KBRemoteLogTarget; KBRemoteLogTarget;
    import com.abc.logs.KBLocalLogTarget; KBLocalLogTarget;
    import com.abc.exception.GlobalExceptionHandler; GlobalExceptionHandler;
    import com.abc.utils.NetConnectionMonitor;NetConnectionMonitor;
}
}

by doing the import followed by the reference of the class you force it to be exported in the code even if it is not used by reference in the code yet

so for symbols and other graphical assets where you use animations etc.
that you want to dynamically change like eyes01, eyes02, eyes03, eyes04, etc.
you force the code to “embed it all”

another way to do it is to keep those symbols as external SWF assets
so when you want to use it in the application you dynamically load the SWF
with the little trick of loading the SWF into an already existing class or interface

so the logic stay the same only the “skin” change

yet another way, if for example there are no animations is to use [Embed] with SVG files

but all that it is a design or an architecture of code, depending on how you do it,
some other things can be easier or harder

so that part -external-library-path vs -library-path I would say is something that need time to understand fully

so let’s try that

from Animate CC you generate
assets.swc that contains

synbol: com.foobar.assets.eyes.Eye01 extend flash.display.MovieClip
synbol: com.foobar.assets.eyes.Eye02 extend flash.display.MovieClip
synbol: com.foobar.assets.eyes.Eye03 extend flash.display.MovieClip

we use MovieClip because the eyes are some kind of :crazy_face: animation built on a timeline

now our Main.as
will use those eyes assets

package
{
    import flash.display.Sprite;
    import com.foobar.assets.eyes.*;

    public class Main extends Sprite
    {
        public function Main()
        {
            if( stage )
            {
                onAddedToStage();
            }
            else
            {
                addEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
            }
        }

        private function onAddedToStage( event:Event = null ):void
        {
            removeEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
            _main();
        }

        private function _main():void
        {
            var eye:MovieClip = new Eye01() as MovieClip;

            addChild( eye );
        }
    }
}

now we compile to merge all the code and assets

$ amxmlc -library-path assets.swc Main.as -output myapp.swf

the myapp.swf will contains all the classes

but if we compile against it but omit the linking

$ amxmlc -external-library-path assets.swc Main.as -output myapp.swf

the compiler will not generate any errors when it sees import com.foobar.assets.eyes.*;
in the sources, it knows it is compiling against that library with -external-library-path assets.swc
but the generated myapp.swf will not contains the code of assets.swc

so when you run myapp.swf you will probably get a runtime error

to make it work you will need to

  • either embed the assets.swc before the code of Main.as is executed
  • or load an external assets.swf file containing the code definitions

load an external assets.swf is what we call an import loading
see Loading display content dynamically
see LoaderContext class

package
{
    import flash.display.Sprite;
    import com.foobar.assets.eyes.*;

    public class Main extends Sprite
    {
        public function Main()
        {
            if( stage )
            {
                onAddedToStage();
            }
            else
            {
                addEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
            }
        }

        private function onAddedToStage( event:Event = null ):void
        {
            removeEventListener( Event.ADDED_TO_STAGE, onAddedToStage );
            _preload();
        }

        private function onComplete( event:Event ):void
        {
            var urlloader:URLLoader = event.target as URLLoader;
            var loader:Loader       = new Loader();

            var AD:ApplicationDomain = ApplicationDomain.currentDomain;

            var context:LoaderContext = new LoaderContext( false, AD );
                context.allowCodeImport = true;
              //context.allowLoadBytesCodeExecution = true;

                loader.loadBytes( urlloader.data, context );

                /* Note:
                   from that point the bytes of `assets.swf`
                   have been loaded in-memory
                   using the same Application Domain
                   and the same Security Domain

                   that means all code definitions from the loaded file
                   are now available to the current context of code
                */
               _main();
        }

        private function _preload():void
        {
            var urlloader:URLLoader = new URLLoader();
                urlloader.dataFromat = URLLoaderDataFormat.BINARY;
                urlloader.addEventListener( Event.COMPLETE, onComplete );
                urlloader.load( new URLRequest( "assets.swf" ) );
        }

        private function _main():void
        {
            var eye:MovieClip = new Eye01() as MovieClip;

            addChild( eye );
        }
    }
}

so you compile with

$ amxmlc -external-library-path assets.swc Main.as -output myapp.swf

-external-library-path assets.swc allow your code to reference such classes as com.foobar.assets.eyes.* without generating an error

and then loading the assets.swf make the code definitions available

or
you can embed the assets.swc before the code of Main.as is executed
and for that you use -frames

frame1.as

package
{
    // for a reference to the assets so there are embedded in this class
    com.foobar.assets.eyes.Eye01; Eye01;
    com.foobar.assets.eyes.Eye02; Eye02;
    com.foobar.assets.eyes.Eye03; Eye03;
    //etc.

    public class frame1
    {

    }
}

and you compile as

$ amxmlc -library-path assets.swc -source-path src/ -frames 1 frame1 -frame 2 Main -output myapp.swf

the code of “assets.swc” will be embedded in frame 1
that means when the code in frame 2 of the Main class will need it
it would have been already “loaded” in memory

Dynamically loading code while being able to compile against it without generating errors can get complicated, even more so on mobile (vs online SWF), personally I find it easier to just embed everything in 1 SWF

Now, changing the way your organise things “after the fact” can be in some case difficult.

1 Like

I see… But even so, I feel like it’s a win-win situation for me. I managed to get started and finish my first project which even if it is bad designed, it “works fine” for the intended target audience (children under the age of 5). I also learnt a lot of knowledge, especially from here, thanks to you!

Well, that was an advice I got from an as3 group in facebook, before I found out this forum here. “In order to avoid the library to flood with symbols so I will have better compilation time and better organized library and to debug each mini game individually” When the told me about swc files, i did not even know that swc files are exist.

I red carefully every piece of information and advice you game me and before I move on, I see if understand correctly what I should have done.

If understood correctly, I put inside a (or more) swf or swc only the assets without any code. But in order to be able to reference the assets some actions required on the swf/swc side, correct? That might be to enable export classes for actionscript? With or without exporting at frame X?
I think that info is an essential missing piece of the puzzle for me.

After making clear some essential things I thing I will be able to try my next project with starling. With starling, I suppose things going to be less forgiving and this time all graphic assets will be embed as Bitmap.

Thank you for your time!

let me be clearer

it is not

it is A design, as you say it works, it allows you to publish an app, it is valid

there is no really bad or good, more like pros and cons

so sorry if my answer look like a let down but imho it is more important to finish a project (whatever the pros and cons) than to “restart it” just to change the design

ok, it seems valid and yeah having part of your app pre-compiled as SWC will make the compilation faster, but it will also force you to recompile those “by hand” if you need to update, so yeah pros and cons.

it is about that, but first let me ask, what are your assets?
do you have animations? not code at all not even a stop() somewhere?
or is it just vector drawing?
do you use like a clip container so you can easily switch different assets (eyes, mouths, teeths, etc.) to test the graphic design?

so remember I don’t know those assets and I don’t know your code
but I would say if you don’t have animations then most or all of those assets could

  • be exported as a SWF and loaded dynamically like you load an image
  • or even better be defined directly in classes with [Embed]

but this is mainly related to a “way of working” with the assets
for ex you could have an eyes.fla where you build your symbols in the Library
and yo export all of those on frame 1

but in the actual FLA you have your assets layout on the timeline in such a way
so you can visually edit/move/review/etc. them

my point is to say that as an asset those are at the end of the code chain, the leaf

the main app code can program and add logic, even work with placeholders
but then load dynamically those assets in the right place

image a Background class where you can load any .png image to actually fill the background
the class can have logic, like ratio-resize based on height or width, transparency, whatever
but the assets itself has no logic, you just load it “in place”

public class Background
{
    public var image:Bitmap;
    //...
}

when you create a var foobar = new Background()
you will reference the image with foobar.image all the time
if no asset loaded you work with a placeholder
and loading the assets allow to change/update the actual bitmap

so the part “be able to reference the assets some actions required on the swf/swc side, correct?”
you can do it a lot of different way but I would advise to not have to depends on code inside the asset itself

you can perfectly have an “advanced” AS3 class with a deep tree structure
of MovieClip or Sprite or Bitmap etc. and just load the assets into it

the AS3 code keep the logic the assets are just replaceable

yes good idea, you need to find your own way to balance the code and the assets

again there are no good or bad design, but depending on the pros and cons,
some things become “easy” or “hard”

try to look into Scout CC too, it will help you seeing a global picture of the whole thing running in term of performance, memory etc.

I do not feel frustrated but more experienced! Even the wrong paths are giving valuable lessons!

Full of animations, some hand drawn dradigital style, many classic tweens, and many many shape tweens! If you try my app, you will see that is more interactive animation than a game. I manipulate the animation with code using frame labels. The very essence of my design, the core of the project is based on interactive animation. I was studying animation when I discovered actionscript. I visualised and created the whole app as animator, not programmer (remember I said new to actionscript and new in programming). To be precise, this project is part of a bigger project of animation and my next games will have the same characters and the same target audience!

Until halfway of developing I was putting everywhere stop(); but I red somewhere that is a bad practice, so I removed most of them. Here and there are still some stop(); in movieclips.

if by clip you mean movieclip yes. I also used empty movieclips in order to put inside other movieclips with code

So looks like at current project this option is off the table.

…And I did not know about scout. Another small useful piece of info I learned today…

In conclusion:

  • Well for sure I keep everything I learnt from you, and I am sure every new project it will be a bit better.
  • At my next projects I’ll try my best to follow the best practices and I will use ant from day 1
  • My current project must leave the beta and go to release version. I will try my final idea, I will compile in animate the fla files without any source code (I will rename the source folder temporarily) and I will copy all the source code into a singe folder and I try again to compile with ant. I think it worth the shot. Every source code I wrote I put in different packages (eg minigame.chameleongame, minigame.colorgame etc). If the compilation fails, then I will compile the release version and I will maintain this project with animate cc.
  • Lesson well learned…

For one more time, thank you very much for your time and effort to help me! I learnt A LOT! You made me get started with ant… I highly appreciate it, and as promised, I will credit you at every future project!

1 Like