简体   繁体   English

如何设置RSL(运行时共享库​​)

[英]How to set up RSL (Runtime Shared Library)

Stack ! 堆叠

I'm having a little trouble setting up a new project (an e-Learning) that I think will benefit a lot from RSL. 我在建立一个新项目(电子学习)时遇到了一些麻烦,我认为这将从RSL中受益匪浅。
My case is something like this: 我的情况是这样的:

Main.fla - A Shell Main.fla-一个外壳
Scenes.fla - I'll explain this in a minute Scenes.fla-我会在稍后解释
Navigation.fla - Some kind of GUI Navigation.fla-一种GUI
Lots Of Fla Files - The Lessons 很多Fla文件 -经验教训

The Main will be the first movie to be instantiated, then, all that is necessary from here will be download . Main将是第一个实例化的电影,然后从此处下载所有必要的内容

Every lesson will be put in a fla/swf apart from the " Architecture " (that is the Main, Scenes, Navigation and a whole bundle of classes called Engine ) and will be added at runtime inside the Scenes. 每节课都将放在fla / swf中,与“ 体系结构 ”(即Main,Scenes,Navigation和一整套名为Engine的类)分开,并将在运行时添加到Scenes中。

The Engine is responsible for handling repetitive and necessary tasks, events, common methods, communication with server, among other things. 该引擎负责处理重复的和必要的任务,事件,通用方法,与服务器的通信等。

The Navigation is responsible for handling user input, as the navigation (next/prev lesson and such), and then passes it to the Engine, that will manipulate the Scenes (and it's children). 导航负责处理用户输入,如导航(上一课/上一课等),然后将其传递给引擎,引擎将操纵场景(及其子场景)。

Well, I have some restrictions too: 好吧,我也有一些限制:
Every swf file that will be handed to our client need to have less than 80kb, which means I'm tied. 每个将交给我们客户的swf文件都必须少于80kb,这意味着我被束缚了。
I can't compile the whole thing as a package ready to delivery. 我无法将整个内容编译为准备交付的软件包。

As size counts, I need means to alleviate the load as much as possible. 随着大小的增加,我需要尽可能减轻负载的方法。
So, I searched a lot these days and found out RSL. 因此,这些天我进行了很多搜索,找到了RSL。
I've created some tests to know better how to use this and, of course, got into a trap. 我创建了一些测试,以更好地了解如何使用它,当然,也陷入了陷阱。

I haven't been able to set up my Flash correct, haven't any success with the "Library Path" (under AS3 configuration), haven't been able to compile classes inside the SWC... 我无法正确设置Flash,使用“库路径”(在AS3配置下)也未成功,也无法在SWC内部编译类...

Another thing is that I won't make the lessons, only the Architecture. 另一件事是,我不会上课,只会上体系结构。
Those lessons will be created by people that may not have any knowledge in AS3 (OOP or program logic) at all. 这些课程将由完全不了解AS3(OOP或程序逻辑)的人们创建。
And I'm not inclined to delivery the whole engine (source code) to anyone from outside that may mess with it, making the whole app (apps, in fact, we'll produce hundreds of e-learnings). 而且我不愿意将整个引擎(源代码)交付给可能与之纠缠的外部人员,从而使整个应用程序(实际上,我们将产生数百个电子学习内容)。

I really think I need help in some things (the clock is ticking away): 我真的认为我在某些方面需要帮助(时钟已经过去了):

How to use RSL efficiently 如何有效使用RSL
How to bundle classes inside the SWC 如何在SWC中捆绑类
How to package all that is imperative for the whole thing work in the SWC, and then, delivery only this SWC 如何在SWC中打包对整个工作至关重要的所有内容,然后仅交付此SWC

I know that this thread is a little bit long, and that I'm asking a lot of things, but I'm cracking my head against the keyboard for a week now, and haven't been able to manage the set up. 我知道这个线程有点长,我要问很多事情,但是现在我已经把头撞到键盘上了一个星期,而且还无法管理设置。

Thank for your attention... 感谢您的关注...
NemoStein NemoStein

There are two ways to do this from an fla 通过fla有两种方法

one is exporting the entire library. 一种是导出整个库。 Go to your publish settings select Flash only and then select Export SWC under the Flash Tab 转到发布设置,选择“仅Flash”,然后在“ Flash”标签下选择“ Export SWC

http://img593.imageshack.us/img593/8296/swc.png http://img593.imageshack.us/img593/8296/swc.png

the other is to right click on an item in your library and select Export SWC. 另一种是右键单击库中的项目,然后选择“导出SWC”。 If you are having issues with items having a size restriction, this might be the way to go, but otherwise I'd recommend exporting the entire library 如果您对具有大小限制的项目有疑问,可以采用这种方法,但否则建议您导出整个库

It is important that you add linkage ids to your assets You can enter this through the linkage id column in your library or by editing the symbol properties. 将链接ID添加到资产中很重要。可以通过库中的“链接ID”列或通过编辑符号属性来输入链接ID。

These IDs need to be unique, as these are the Classes' names you will call them by. 这些ID必须是唯一的,因为这些是您将使用它们的类的名称。 It is a good idea to create a common prefix, so they're unlikely to interfere with other classes. 创建公共前缀是一个好主意,因此它们不太可能干扰其他类。

http://img827.imageshack.us/img827/7820/linkageid.png http://img827.imageshack.us/img827/7820/linkageid.png

When you have your assets compiled, you can either add them to your project's runtime library folder or embed them one-by-one through settings or the embed tag. 编译资产后,可以将其添加到项目的运行时库文件夹中,也可以通过设置或embed标签将它们一一嵌入。 I use FlashDevelop which makes it easy, not sure what you are using, butI'm sure the option is there and easily accessible. 我使用FlashDevelop可以很容易地(不确定您使用的是什么),但是我确定该选项在那里并且可以轻松访问。


Using Libraries. 使用库。

What I've been doing for loading assets (swf at runtime) Why run-tim swfs ? 我一直在做的事情来加载资产(运行时的swf)为什么要运行-tim swfs? Well, you really cannot keep the engine separate if you are compiling it for the content. 好吧,如果您针对内容进行编译,则确实无法将引擎分开。 The idea is that the engine is loaded first, and then loads the configuration that tells it how to handle libraries and where to find each one. 这个想法是先加载引擎,然后加载配置,告诉它如何处理库以及在何处找到每个库。

my setup/getup simplified is something like this 简化的设置/获取是这样的

I have a default configuration xml file that where libraries are added. 我有一个默认配置xml文件,其中添加了库。 For my purposes, I know the expected libraries so I have xml tags with predifined ids like this: 就我的目的而言,我知道预期的库,因此我有带有预定义ID的xml标记,如下所示:

on the code side I would define the names/types of libraries as a constant static and put all of them in another constant that's an array. 在代码方面,我将库的名称/类型定义为一个常量静态变量,并将它们全部放在另一个常量数组中。 Something like this in my Data class const static var TYPE_COMPONENTS:String = "components"; 在我的Data类中,类似这样的内容const static var TYPE_COMPONENTS:String =“ components”; const static var TYPE_INTERFACE:String = "interface"; const static var TYPE_INTERFACE:String =“ interface”; const static var TYPES:Array = [TYPE_COMPONENTS,TYPE_INTERFACE]; const static var TYPES:Array = [TYPE_COMPONENTS,TYPE_INTERFACE];

once I get the confg xml loaded, and can go through the child nodes one by one and see if they match any items under my TYPES array. 一旦我加载了confg xml,就可以一个接一个地遍历子节点,看看它们是否与我的TYPES数组下的任何项目匹配。 I put all the matches in a group loader ( http://as3.casalib.org/docs/org_casalib_load_GroupLoad.html ) I also put all the resources into a dictionary array, so that I can assets by the static vars' I defined (Data.TYPE_INTERFACE) 我将所有匹配项都放入了一个组加载器( http://as3.casalib.org/docs/org_casalib_load_GroupLoad.html )中,我还将所有资源都放入了一个字典数组中,以便可以通过我定义的静态vars进行资产化( Data.TYPE_INTERFACE)

Then I wait for the loading to finish. 然后,我等待加载完成。

Once it comes to loading the assets, I use getLoader(Data.TYPE_INTERFACE). 一旦涉及到加载资产,我将使用getLoader(Data.TYPE_INTERFACE)。 getDefinition ( myClassName ) to create the class 使用getDefinitionmyClassName )创建类

it helps to have hasDefinition to check if the class exsits without throwing an error hasDefinition可以检查类是否存在而不会引发错误,这很有帮助

You need to know what the class name is to call it, I use another XML file that defines what classes to look for and how to treat them. 您需要知道该类的名称是什么,我使用另一个XML文件来定义要查找的类以及如何使用它们。

I generate the XML files by hand and sometimes need to remind myself what the options are, but it would be possible to create an AIR app that could generate these files. 我手动生成XML文件,有时需要提醒自己这些选项是什么,但是可以创建一个可以生成这些文件的AIR应用程序。 Because I'm using an swf as an engine running on a pc, there is no way of finding what the libraries are present in a child folder, as you could with servers side technologies or AIR, so XML is a necessity. 因为我将swf用作在PC上运行的引擎,所以无法找到子文件夹中存在的库,就像使用服务器端技术或AIR一样,因此XML是必需的。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM