actionscript 3 - Flash/Flex error 1067: can't make a custom TextFormat object? -


because I want to avoid duplication of code, and I'm using a lot of text formats, I CustomTextFormat in Flex Category Building Builder

Using this object is another class, said CustomInputBox.as to create a format:

  package {import flash.display.Sprite; Import Flash. Text. Textfield; Import Flash.text.TextFieldType; Public class CustomInputBox extends Sprite {public function CustomInputBox (xLoc: integer, YLoc: integer, width: uint, height: uint, password: Boolean = false, text: String = ""; font: String = "Arial", FONTCOLOR: uint = 0x000000, fontSize: uint = 18, fontBold: boolean = false) {var input box: 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: custom text format = new custom text format (); InputBox.defaultTextFormat = Format; Inputbox.text = text; AddChild (InputBox); }}}  

The code for CustomTextFormat is as follows:

  package {import flash.display.Sprite; Import Flash. Text. Text format; 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 text format (); Format.font = font; Format.color = fontColor; Format.size = fontSize; Format.bold = fontBold; Format.align = fontAlign; }}}  

Now, I'm getting an error Kstminput Bokskas file in 1067, it is unfortunately a Dutch error (no way to set the Flex errors in English?):

1067: TextFormat: Impliciete een niet-gerelateerd type van flash.text een waarde van het type CustomTextFormat omzetting afgedwongen. CustomInputBox.as

Translation is difficult, but hopefully the error number and code are enough to identify my problem. I'm new to Flash, and searched but I did not know what I'm doing.

Thanks in advance.

Here's something unique if you want to assign your custom format as follows:

  var format: custom text format = new custom text format (); InputBox.defaultTextFormat = Format;  

Then CustomTextFormat needs to be expanded to TextFormat, and the inherited code in CustomTextFormat should be modified in the TF property. Alternatively, if you want to leave the custom text extension sprite, then you need to convert the custom format format "format" property into public property, and change your assignment to something like this:

  var customFormat: CustomTextFormat = new custom text format (); Inputbox.defaultTextFormat = customFormat.format;  

Does this mean? You are currently trying to set the default text format of input in the class object, which is expanded to spread. And the Inputbox does not know anything about the custom text format's internal "format" property, which is both private and temporary.

(Incidentally, any such error message is telling you, but in my experience this flash compiler errors actually tells you what is wrong ... There is something rare for ... they claim that you are using classes illegally when you leave all semicolons. I do not believe in error messages too much.)


Comments