因为我想避免重复的代码,并且我使用了很多文本格式,所以我在Flex Builder中创建了一个CustomTextFormat类。Flash/Flex错误1067:无法创建自定义的TextFormat对象?
另一类,称为CustomInputBox.as使用这个对象来创建格式:
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
public class CustomInputBox extends Sprite
{
public function CustomInputBox(xLoc:int, yLoc:int, width:uint, height:uint, password:Boolean = false, text:String = "", font:String = "Arial", fontColor:uint = 0x000000, fontSize:uint = 18, fontBold:Boolean = false)
{
var inputBox:TextField = new TextField();
inputBox.type = TextFieldType.INPUT;
inputBox.mouseEnabled = true;
inputBox.selectable = true;
inputBox.multiline = false;
inputBox.x = xLoc;
inputBox.y = yLoc;
inputBox.width = width;
inputBox.height = height;
inputBox.displayAsPassword = password;
var format:CustomTextFormat = new CustomTextFormat();
inputBox.defaultTextFormat = format;
inputBox.text = text;
addChild(inputBox);
}
}
}
CustomTextFormat的代码如下:
package
{
import flash.display.Sprite;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
public class CustomTextFormat extends Sprite
{
public function CustomTextFormat(font:String = "Arial", fontColor:uint = 0x000000, fontSize:uint = 18, fontBold:Boolean = false, fontAlign:String = TextFormatAlign.LEFT)
{
var format:TextFormat = new TextFormat();
format.font = font;
format.color = fontColor;
format.size = fontSize;
format.bold = fontBold;
format.align = fontAlign;
}
}
}
现在,我收到提示1067在CustomInputBox.as文件中,不幸的是(将flex错误设置为英语的任何方式?):
1067:在een niet-gerelateerd类型中使用CustomTextFormat类型flash.text:TextFormat。 CustomInputBox.as
这很难翻译,但希望错误号码和代码足以识别我的问题。我是新来的Flash,并搜索,但无法找出我做错了什么。
在此先感谢。
非常感谢。这会让我更进一步。 我的问题是我真的不知道扩展是什么,我只是默认使用Sprite。我真的需要找到一个... – Tom 2009-06-24 09:58:00