1
爲了在我的文本框中使用像素字體,我在Flash IDE中創建了一個字體類。然後,我創建了一個TextField實例,其中嵌入了反鋸齒的字體設置爲位圖。我用這些東西出口SWC。AS3:無法輸入帶有嵌入像素字體的輸入TextField
我創建了一個具有良好API的類,可以輕鬆處理這些東西。
在FDT中,我使用類,這一切正常工作。
這裏的問題是我現在想要使用這些文本字段之一作爲輸入。我嘗試將textfield類型設置爲TextFieldType.INPUT,但是唯一的做法是允許我選擇文本,但不能輸入。我還創建了另一個已經設置爲輸入類型的資產,也不起作用。
我試着用資產,而不是用我的課,然後我可以輸入ok。
是否有東西可以防止文本字段在它成爲精靈的一部分時被編輯?這裏是我的API的代碼:
package net.jansensan.as3fflikeui.text
{
// + ----------------------------------------
// [ IMPORTS ]
// + ----------------------------------------
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.text.TextFieldType;
/**
* @author Mat Janson Blanchet
*/
public class BitmapTextfield extends Sprite
{
// + ----------------------------------------
// [ CONSTANTS ]
// + ----------------------------------------
[Embed(source="../assets/css/ui.css", mimeType="application/octet-stream")]
private const CSS :Class;
// + ----------------------------------------
// [ VARIABLES ]
// + ----------------------------------------
// display objects
private var _textfieldAsset :MovieClip;
private var _textfield :TextField;
private var _shadow :BitmapTextfieldAsset;
// private/protected
private var _styleSheet :StyleSheet;
// + ----------------------------------------
// [CONSTRUCTOR ]
// + ----------------------------------------
public function BitmapTextfield(type:String = TextFieldType.DYNAMIC)
{
switch(type)
{
case TextFieldType.DYNAMIC:
_textfieldAsset = new BitmapTextfieldAsset();
_textfield = _textfieldAsset.textfieldTXT;
_textfield.selectable = false;
break;
case TextFieldType.INPUT:
_textfieldAsset = new BitmapInputTextfieldAsset();
_textfield = _textfieldAsset.textfieldTXT;
_textfield.selectable = true;
break;
}
_textfield.htmlText = "";
_shadow = new BitmapTextfieldAsset();
_shadow.textfieldTXT.htmlText = "";
_shadow.x = 1;
_shadow.y = 1;
_styleSheet = new StyleSheet();
_styleSheet.parseCSS(new CSS());
setStyle(_styleSheet);
addChild(_shadow);
addChild(_textfieldAsset);
}
// + ----------------------------------------
// [ PUBLIC METHODS ]
// + ----------------------------------------
public function setWidth(newWidth:int):void
{
_textfield.width = newWidth;
_shadow.textfieldTXT.width = newWidth;
}
public function setHeight(newHeight:int):void
{
_textfield.height = newHeight;
_shadow.textfieldTXT.height = newHeight;
}
public function setStyle(newStyle:StyleSheet):void
{
_styleSheet = newStyle;
_textfield.styleSheet = _styleSheet;
}
public function setText(newText:String):void
{
_textfield.htmlText = newText;
_shadow.textfieldTXT.htmlText = newText;
}
public function getText():String
{
return _textfield.text;
}
public function getHTMLText():String
{
return _textfield.htmlText;
}
public function getTextNumLines():uint
{
return _textfield.numLines;
}
}
}
任何指導將是有用的,在此先感謝!
-mat。
它是否按預期使用非嵌入式字體? – Cameron