[英]How about using FLEX 3 component inside Flash file?
Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ? 是否可以在Flash(cs4)SWF文件中使用Flex 3组件/代码?
I know its possible in the opposite direction. 我知道它有可能朝相反的方向发展。
I haven't used Flex code in a "pure AS3" project myself, but I don't see why you couldn't do that. 我自己没有在“纯AS3”项目中使用Flex代码,但是我不明白为什么您不能这样做。
You can download the Flex SDK and get the Flex components from there, both as an swc
file (under /frameworks/libs
) and as AS3 source code (under /frameworks/projects/framework/src
). 您可以下载Flex SDK并从那里获取Flex组件,既可以是
swc
文件(在/frameworks/libs
),也可以是AS3源代码(在/frameworks/projects/framework/src
)。
With my minimal testing it seems you can't use Flex components when building a "pure AS3" project. 通过我的最少测试,似乎在构建“纯AS3”项目时无法使用Flex组件。 (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)
(我们可以开始称它为PAS3之类的吗?例如“passé”。还是“ pastry”。:)
I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would instantiate and addChild one mx.controls.Button. 我通过创建一个具有一个AS类作为“文档类”的测试项目来进行有限的测试,该实例将实例化并添加一个mx.controls.Button子项。 I copied the whole mx package from the path mentioned by hasseg into the project source path.
我将整个mx包从hasseg提到的路径复制到了项目源路径。
This is what I found out: 这是我发现的:
In general you need to use MXML to initialise the Flex framework and use Flex components. 通常,您需要使用MXML初始化Flex框架并使用Flex组件。
Mike Chambers from Adobe says: Adobe的Mike Chambers说:
There is not support for using the Flex Framework in an AS only project.不支持仅在AS项目中使用Flex Framework。 While it is theoretically possible, you would have to manually bootstrap a lot of the application initialization code that Flex handles (something which would be rather complex).
虽然从理论上讲是可行的,但您必须手动引导Flex处理的许多应用程序初始化代码(这会相当复杂)。 - Source
- 来源
To see how complex, you can tell the compiler to keep the intermediate AS3 files that it generates from the MXML. 要了解其复杂程度,您可以告诉编译器保留从MXML生成的中间AS3文件。 Open your AS3 project properties and set
-keep-generated-actionscript
as an argument to the compiler. 打开AS3项目属性,并将
-keep-generated-actionscript
为编译器的参数。 Compile your project then look in the obj/generated folder. 编译项目,然后在obj / generated文件夹中查找。 Using Flex 4, I get 13 small files the main of which extends
spark.components.Application
and overrides a few methods. 使用Flex 4,我获得了13个小文件,它们的主要扩展了
spark.components.Application
并覆盖了一些方法。
So it's possible but you probably wouldn't want to do it. 因此有可能,但您可能不想这样做。 Flex is meant to make your life easier, not harder.
Flex旨在使您的生活更轻松,而不是更艰难。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.