表单元素不会出现在输出中

时间:2011-12-17 06:44:37

标签: actionscript-3 flash-builder4.5

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

enter image description here

然而,当我运行/调试它时,没有任何内容出现在那里。完全白了。

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

是否有任何特殊原因导致它无法在Flash Builder中运行?

UPDATE:当我在文本输入中添加图形时,即

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

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

4 个答案:

答案 0 :(得分:1)

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

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

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

TextInput(页面底部)

的示例

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

Flex的样本

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

答案 1 :(得分: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;
}

请同时查看the TextField docs

答案 2 :(得分:1)

试试这个:

在Flash Professional中创建新的FLA。将TextInput组件添加到库中。请注意,TextInput类不仅会添加到库中,还会添加“Component Assets”文件夹 - 皮肤等。 Flash Professional组件不仅仅是代码 - 它们是代码和图形。

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

答案 3 :(得分:0)

为什么要将你的控制添加到舞台上?您应该将其添加到表单中。即this.addChild(ti)