从 Flash 导出 SWC 并从 Flex 访问子项 [英] Export SWC from Flash and Access Child from Flex

查看:22
本文介绍了从 Flash 导出 SWC 并从 Flex 访问子项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Flex Builder 中创建一个 actionscript 项目.我成功地从 Flash 导出一个 SWC 文件,并在 Flex 中成功使用它.我有很好的编程背景,Flex 对我来说看起来很简单,但我在 Flash 中遇到了困难.

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):

我在 Flash 中创建了一个简单的形状,并将其转换为符号.然后我创建了一个 TextField.I 选择两个元素并将它们转换为另一个符号,然后将其导出为 swc 中的影片剪辑.

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.

在 flex 中,我想更改文本字段中的值.我应该怎么做?我正在尝试:

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)

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

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?

推荐答案

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

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.

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

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,...).

例如,如果您有一个包含 TextField 控件的 ExportedMC 符号,您为其提供了实例名称(例如,'txtFieldName'),您可以像这样在 Flex 中访问它:

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 实际上能够自动完成类上的属性名称,因此您可以轻松知道事情是否成功.

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.

希望这会有所帮助.

这篇关于从 Flash 导出 SWC 并从 Flex 访问子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆