How can I add ActionScript 3 import statements to LZX class definitions with OpenLaszlo 5.0?

别说谁变了你拦得住时间么 提交于 2019-12-11 10:07:59

问题


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

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