How to generate the ActionScript 3 source code of an OpenLaszlo LZX SWF runtime app

人走茶凉 提交于 2019-12-08 07:35:43

问题


When developing OpenLaszlo applications, it's sometimes useful to generate the ActionScript 3 source code of an application written in lzx, e.g. when you want to compile OpenLaszlo into an Adobe AIR application.

What is the simplest way to generate the ActionScript 3 source code into a predefined folder?


回答1:


The lzc command line tool which can be found in the $LPS_HOME/WEB-INF/lps/server/bin/ has on option for that:

--lzxonly
  for as3 runtime, emit intermediate as files, 
  but don't call backend as3 compiler

By default the OpenLaszlo compiler will generate the ActionScript 3 code into the system specific Java temp folder, but the $JAVA_OPTS environment variable can be used to change that folder.

Here's an example of how the command can be used in combination with $JAVA_OPTS on Linux:

a) Create a simple LZX file, e.g.

<canvas>  
  <button text="Hello world" />  
</canvas>

and save it as test.lzx.

b) Set the $JAVA_OPTS variable
The following syntax is for Linux or OS X:

export JAVA_OPTS="-Djava.io.tmpdir=./tmp -DXmx1024M"

c) Compile the LZX into ActionScript 3

> lzc --lzxonly test.lzx --runtime=swf10
Compiling: test.lzx to test.swf10.swf

The tmp folder will contain the generated ActionScript 3 files

tmp
├── lzccache
└── lzswf9
    └── build
        └── test
            ├── app.swf
            ├── build.sh
            ├── LzApplication.as
            ├── $lzc$class_basebutton.as
            ├── $lzc$class_basecomponent.as
            ├── $lzc$class_basefocusview.as
            ├── $lzc$class_button.as
            ├── $lzc$class__componentmanager.as
            ├── $lzc$class_focusoverlay.as
            ├── $lzc$class__m2u.as
            ├── $lzc$class__m2v.as
            ├── $lzc$class__m2w.as
            ├── $lzc$class__m2x.as
            ├── $lzc$class__m2y.as
            ├── $lzc$class__m2z.as
            ├── $lzc$class__m30.as
            ├── $lzc$class__m31.as
            ├── $lzc$class__mm.as
            ├── $lzc$class__mn.as
            ├── $lzc$class__mo.as
            ├── $lzc$class__mp.as
            ├── $lzc$class_statictext.as
            ├── $lzc$class_style.as
            ├── $lzc$class_swatchview.as
            ├── LZC_COMPILER_OPTIONS
            ├── LzPreloader.as
            └── LzSpriteApplication.as

The folder structure follows the following scheme:

{JAVA_TEMP_FOLDER}/lzswf9/build/{LZX_FILENAME_WITHOUT_ENDING}, therefore in our case

tmp/lzswf9/build/test/

The main applicaton file is LzSpriteApplication.as, and you can look into the build.sh file to get an idea how the Flex SDK's mxmlc command is used to compile the generated source code.



来源:https://stackoverflow.com/questions/13008487/how-to-generate-the-actionscript-3-source-code-of-an-openlaszlo-lzx-swf-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!