模块化和弹性视图状态

发布于 2024-10-04 02:22:10 字数 259 浏览 0 评论 0原文

我见过一些类似的问题,但没有什么像我想要弄清楚的那样,所以这里是。我有一个具有许多视图状态的 Flex 应用程序,其中一些经常使用,一些则不经常使用。目前,所有这些状态都驻留在一个 mxml 文件中,因此只会生成一个 swf 文件并在客户端浏览器中加载。我想通过将这些视图状态分成不同的源文件并将状态从一个文件加载到另一个文件中来模块化这些视图状态,但是,我仍然希望用户只需加载一个 swf 文件。我这样做的主要原因是避免源文件超过 10,000 行。有解决这个问题的标准方法吗?

谢谢。

I've seen some similar questions, but nothing quite like what I'm trying to figure out, so here goes. I have a flex app with many view states, some of which are used frequently, some of which are not. Currently all these states reside in one mxml file so that only one swf file is generated and loaded in the client browser. I would like to modularize these view states by separating them out into different source files and just loading states from one file into another, however, I still want the user to only have to load one swf file. My main reason for this is to avoid having source files in excess of 10,000 lines. Is there a standard way of addressing this issue?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放低过去 2024-10-11 02:22:10

有两种方法可以满足您的要求。第一个是你所问的,第二个是我推荐的。

首先:

创建 main.mxml 应用程序,然后为每个状态创建单独的 component1.mxml 和 component2.mxml 文件。然后在您的应用程序中进行如下设置:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
    <s:states>
        <s:State name="State1"/>
        <s:State name="State2"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <local:Component1 includeIn="State1"/>
    <local:Component2 includeIn="State2"/>
</s:Application>

第二种方式,也是我推荐的一种方式,因为您对应用程序的描述将其分解为具有一个 swf 应用程序的多个 swf 模块。这样用户只下载他们计划使用的内容。在此场景中,执行与之前相同的操作,但创建模块而不是组件。

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
    <s:states>
        <s:State name="State1"/>
        <s:State name="State2"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:ModuleLoader url="Component1.swf" includeIn="State1"/>
    <mx:ModuleLoader url="Component2.swf" includeIn="State2"/>
</s:Application>

There are two ways of doing what you ask. The first is what it sounds like you are asking, the second is what I would recommend.

First:

Create your main.mxml application and then create separate component1.mxml and component2.mxml files for each of your states. Then in your application set it up like this:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
    <s:states>
        <s:State name="State1"/>
        <s:State name="State2"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <local:Component1 includeIn="State1"/>
    <local:Component2 includeIn="State2"/>
</s:Application>

The second way, and the one I recommend because of your description of the application breaks it down into multiple swf modules with one swf application. This way the user only downloads what they plan to use. In this scenario do the same as before but create modules instead of components.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
    <s:states>
        <s:State name="State1"/>
        <s:State name="State2"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:ModuleLoader url="Component1.swf" includeIn="State1"/>
    <mx:ModuleLoader url="Component2.swf" includeIn="State2"/>
</s:Application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文