从 Flash 导出 SWC 并从 Flex 访问子项

发布于 2024-08-25 10:00:52 字数 481 浏览 9 评论 0原文

我正在 Flex Builder 中创建一个动作脚本项目。我成功从 Flash 导出 SWC 文件,并在 Flex 中成功使用它。我有良好的编程背景,Flex 对我来说看起来很简单,但我在 flash 方面遇到了困难。

我正在尝试实现一些可能非常简单的事情(当然不适合我):

我在 Flash 中创建一个简单的形状,将其转换为符号。然后我创建一个文本字段。我选择这两个元素并将它们转换为另一个元件,然后将其导出为 swc 中的影片剪辑。

在 Flex 中,我想更改文本字段中的值。我该怎么办?我正在尝试这样做:

var t:ExportedMC = new ExportedMC();
t....(what should I write here)

正如我提到的,当我打开闪光灯时,我感觉就像瓷器店里的大象。我这里有两个问题: - 如何为 Flash 中的文本字段指定名称?我用的是CS4。 - 如何在 Flex 中作为孩子访问它?

I'm creating an actionscript project in Flex Builder. I succeed to export from Flash a SWC file, and to use it succesfully in Flex. I have a good programming background and Flex looks very simple for me, but I have difficult times in flash.

I'm trying to achieve something that might be very simple(not for me of course):

I create a simple shape in Flash, convert it to symbol. Then I create a TextField. The I select both the elements and convert them to another symbol, and Export it as a movieclip in swc.

In flex I want to change the value from the textfield. How should I do? I'm trying to do:

var t:ExportedMC = new ExportedMC();
t....(what should I write here)

As I mentioned when I open flash I feel like an elephant in a porcelain store. I have 2 questions here:
- how to assign a name to the textfield in flash? I'm using CS4.
- how to access it as a child in flex?

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

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

发布评论

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

评论(1

归途 2024-09-01 10:00:52

当您在 Flash 中创建元件并将其导出到 ActionScript(在元件属性对话框中)时,您创建了一个可在 Flex 中访问的类(在将生成的 swc 包含在 Flex 项目库路径中之后)。该类中的任何控件/形状/符号都将包含在包含类中并与包含类一起创建。

如果您想要访问/修改该类中的任何对象/smybols/任何内容,则需要为它们提供一个实例名称(您可以不执行此步骤,但会更复杂)。在 Flash 中,您可以编辑(双击)库中的类对象,然后在类对象中选择特定的子对象/符号/控件,并通过在对象属性选项卡下输入内容为其指定名称。该名称将作为属性包含在导出的类中,您可以像任何其他类属性(宽度、高度、x、y...)一样访问该属性。

例如,如果您有一个 ExportedMC 符号,其中包含一个您指定了实例名称(例如“txtFieldName”)的 TextField 控件,则您可以在 Flex 中访问它,如下所示:

var t:ExportedMC = new ExportedMC();
t.txtFieldName.text="something";

Flex 实际上能够自动完成类上的属性名称,这样您就可以轻松地知道事情是否成功。

希望这有帮助。

When you create the symbol in Flash and export it to actionscript (in symbol properties dialog), you created a class that is accessible in Flex (after including the resultant swc in flex project library path). Any controls/shapes/symbols within that class will be contained within and created along with the containing class.

If you have any objects/smybols in that class that you would like to access/modify/whatever, you need to give them an instance name (you can do it without this step, but it's more complicated). In Flash, you edit (doubleclick) the class object in the library, then select a particular sub-object/symbol/control in the class object and give it a name by entering something under in object properties tab. That name will be included in the exported class as an property that you can access as any other class property (width,height,x,y,...).

For example, if you have a ExportedMC symbol that includes a TextField control which you gave instance name ('txtFieldName', for example), you would access it in Flex like so:

var t:ExportedMC = new ExportedMC();
t.txtFieldName.text="something";

Flex will actually be able to autocomplete the property name on the class, so you'll easily be able to know if things worked out or not.

Hope this helps.

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