如何从 Flex 应用程序读取 Flash SWF 中文本输入的值?

发布于 2024-07-06 07:49:40 字数 353 浏览 10 评论 0原文

我有一个 Flex 应用程序,它从 CS3 加载 SWF。 加载的 SWF 包含一个名为“myText”的文本输入。 我可以在 SWFLoader.content 中看到这一点,没有任何问题,但我不知道我应该在我的 Flex 应用程序中将其视为什么类型。 我认为 Flex 文档涵盖了这一点,但我只能找到如何与另一个 Flex SWF 交互。

Flex 调试器告诉我它的类型是 fl.controls.TextInput,这是有道理的。 但FlexBuilder似乎不知道这个类。 虽然 Flash 和 Flex 都使用 AS3,但 Flex 拥有全新的 GUI 类库。 我以为它也有所有的 Flash 类,但我无法让它知道任何 fl.*** 包。

I have a Flex application, which loads a SWF from CS3. The loaded SWF contains a text input called "myText". I can see this in the SWFLoader.content with no problems, but I don't know what type I should be treating it as in my Flex App. I thought the flex docs covered this but I can only find how to interact with another Flex SWF.

The Flex debugger tells me it is of type fl.controls.TextInput, which makes sense. But FlexBuilder doesn't seem to know this class. While Flash and Flex both use AS3, Flex has a whole new library of GUI classes. I thought it also had all the Flash classes, but I can't get it to know of ANY fl.*** packages.

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

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

发布评论

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

评论(3

沦落红尘 2024-07-13 07:49:40

fl.* 类层次结构仅适用于 Flash CS3。 它是 Flash Components 3 库(我相信它被称为,我可能是错的)。 但是,您不需要该类来处理该对象。 只要您可以在代码中获得对它的引用(您似乎已经拥有了),您就可以将该引用分配给无类型变量并无论如何使用它:

var textInput : * = getTheTextInput(); // insert your own method here

textInput.text = "Lorem ipsum dolor sit amet";

textInput.setSelection(4, 15);

无需知道对象的类型即可进行交互用它。 当然,您会在编译时丢失类型检查,但这实际上不是什么大问题,您只需格外小心即可。

如果您确实非常想引用该对象作为其实际类型,则相关类位于

Adobe Flash CS3/Configuration/Component Source/ActionScript 3.0/User Interface/fl/controls/TextInput.as

...如果您安装了 Flash CS3,因为它仅随该应用程序一起提供。

The fl.* hierarchy of classes is Flash CS3-only. It's the Flash Components 3 library (I believe it's called, I might be wrong). However, you don't need the class to work with the object. As long as you can get a reference to it in your code, which you seem to have, you can assign the reference to an untyped variable and work with it anyway:

var textInput : * = getTheTextInput(); // insert your own method here

textInput.text = "Lorem ipsum dolor sit amet";

textInput.setSelection(4, 15);

There is no need to know the type of an object in order to interact with it. Of course you lose type checking at compile time, but that's really not much of an issue, you just have to be extra careful.

If you really, really want to reference the object as its real type, the class in question is located in

Adobe Flash CS3/Configuration/Component Source/ActionScript 3.0/User Interface/fl/controls/TextInput.as

...if you have Flash CS3 installed, because it only ships with that application.

寄离 2024-07-13 07:49:40

Flex 和 Flash SWF 本质上是相同的,只是使用不同的工具构建。 我不确定它们是否共享相同的组件库,但根据包名称,我猜测它们至少大部分是共享的。

如果它是一个普通的文本输入,那么我猜它是 mx.controls.TextInput 的一个实例。

Flex and Flash SWFs are essentially the same, just built using different tools. I'm not sure if they share the same component libraries, but based on the package names I'm guessing they at least mostly do.

If it's a normal Text Input then I would guess it's an instance of mx.controls.TextInput.

秋千易 2024-07-13 07:49:40

请记住,如果您按照 Theo 所说的操作并使用正确的类型引用它,它将在两个 swf 中编译该类,即使您没有在第一个 swf 中使用它。 不幸的是 fl.* 类没有实现任何接口,因此您不能将它们键入接口而不是实现。 如果可以的话,只有接口会被编译,这比实现小得多。 对于这个来说,这不是什么大问题,它可能只会增加几 kb,但从长远来看,它会增加。 请注意;)

Keep in mind that if you do as Theo said and reference it with the correct type it will compile that class in both swfs, even if you're not using it in the first one. Unfortunately the fl.* classes don't implement any interfaces so you can't type them to the interface instead of the implementation. If you could, only the interface would get compiled, which is much smaller than the implementation. For this one it won't be a big deal, it's probably going to add only a couple kb, but in the long run it adds up. Just a heads up ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文