1

我在 Flash Builder 4.5 中创建了一个 Flex 项目。接下来,我在项目中添加了 fl.controls 库(然后是 mx.controls 库)。我正在添加一个屏幕截图,以便您可以查看设置和代码。

在此处输入图像描述

但是,当我运行/调试它时,那里什么都没有出现。全白。

我以前使用过 fl.controls,我使用 Flash CS5 编译 ActionScript 项目,它们工作正常。

它在 Flash Builder 中不起作用有什么特别的原因吗?

更新:当我将图形添加到文本输入时,即

ti.graphics.beginFill(0xFF0000);
ti.graphics.drawRect(0, 0, 100, 30);
ti.graphics.endFill();

我确实看到了一个红色的矩形形状。但仍然没有可编辑的文本输入框。我尝试设置ti.editable = true但没有用。

4

4 回答 4

1

我更喜欢使用 Flex 本身,它会加快你的开发速度。这很简单,并且为您做了很多工作。

如果您不想这样做,您应该为您的文本提供一些属性,例如width, heighttextFormat或使用 css 文档作为文本格式。你也可以给你的文本一个边框(它应该是 TextInput 的一个属性)。

不要忘记设置文本格式,否则 TextField 不知道使用哪种字体。

TextInput 示例(页面底部)

http://help.adobe.com/de_DE/FlashPlatform/reference/actionscript/3/fl/controls/TextInput.html

弹性样品

http://help.adobe.com/de_DE/FlashPlatform/reference/actionscript/3/spark/components/RichEditableText.html

于 2011-12-19T09:36:03.403 回答
1

你可以试试这段代码:

private var ti:TextField = new TextField();

public function FormText(){
    //adds ti possibly underneath 'this': stage.addChild(ti);
    //adds ti on top of 'this':
    stage.addChildAt(ti,getChildIndex(this));

    // makes the TextField editable:
    ti.type = TextFieldType.INPUT;
}

这不仅要确保在类实例化时 TextField 存在,而且还要将表单放在类的前面

但这也是假设该类已添加到阶段;所以最好像这样添加它:

private var ti:TextField = new TextField();

public function FormText(){
    addEventListener(Event.ADDED_TO_STAGE, addedHnd);
}

private function addedHnd(e:Event)
{
    removeEventListener(Event.ADDED_TO_STAGE, addedHnd);

    //adds ti possibly underneath 'this': stage.addChild(ti);
    //adds ti on top of 'this':
    stage.addChildAt(ti,getChildIndex(this));

    // makes the TextField editable:
    ti.type = TextFieldType.INPUT;
}

请也查看TextField 文档

于 2011-12-20T05:54:22.270 回答
1

试试这个:

在 Flash Professional 中创建一个新的 FLA。将 TextInput 组件添加到您的库中。请注意,不仅 TextInput 类被添加到库中,而且还添加了“组件资产”文件夹 - 皮肤等。Flash Professional 组件不仅仅是代码 - 它们是代码和图形。

如果您想在 Flash Builder 中使用 fl.controls.TextInput,您可以发布刚刚创建的 FLA,并选中“export swc”选项。在您的 Flash Builder 项目中包含该 swc,您将能够在代码中实例化 TextInput。如果要添加其他 Flash 组件,请将它们添加到 FLA 中的库并重新发布 swc。

于 2011-12-21T03:21:36.197 回答
0

为什么要在舞台上添加控件?您应该将其添加到您的表单中。IEthis.addChild(ti)

于 2011-12-17T06:47:27.103 回答