问题
I'm working on an OpenLaszlo application using the unreleased version of OpenLaszlo 5.0 (trunk). In one of my classes I need to import ActionScript 3 classes. What is the recommended way to add such import statements?
回答1:
LZX supports the passthrough tag. The passthrough tag in turn has a when attribute, where you can specify a boolean expression, e.g. $as3 or $swf10:
<canvas debug="true">
<class name="foo">
<passthrough when="$as3">
import flash.system.Capabilities;
</passthrough>
<handler name="oninit">
if ($as3) {
Debug.info(Capabilities.os);
} else {
Debug.info("flash.system.Capabilities can only be used in the SWFx runtime");
}
</handler>
</class>
<foo />
</canvas>
For the SWFx runtime, the import statement is then injected into the genereated ActionScript 3 class.
来源:https://stackoverflow.com/questions/11881562/how-can-i-add-actionscript-3-import-statements-to-lzx-class-definitions-with-ope