-
11-07-2019 - |
题
任何人都不会知道如何创建一个动态的文本区域有一个可见边界和圆角AS3?
我想我可能需要创建一个圆形的影片剪辑,调整并将其背后的文本。
我试过,但是我没有看到任何改变。
var styleRound:StyleSheet = new StyleSheet();
styleRound.parseCSS("h4{cornerRadius:10;borderStyle: solid; borderThickness: 1;}");
tf.htmlText = "<h4>" + hotspotData.caption + "</h4>";
tf.styleSheet = styleRound;
解决方案
这是一个列表中的 提供的样式对于文本框在ActionScript3.对不起,有没有一个角落的半径。
你可以把上一个边界对一个文本编辑框于文本框目 边境酒店.但没有一个酒店提供给全的角落。
我建议你创造了一个新的组成部分并加入边界的自己作为一个精灵下面文本框.是这样的:
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class TextBorder extends Sprite
{
private static const CORNER_RADIUS:int = 5;
// display objects
private var background:Sprite;
private var field:TextField;
// properties
private var _text:String;
public function TextBorder()
{
background = new Sprite;
field = new TextField;
field.autoSize = TextFieldAutoSize.LEFT;
addChild(background);
addChild(field);
// TESTING:
text = "Hello World";
}
public function set text(newText:String):void
{
_text = newText;
display();
}
public function get text():String
{
return _text;
}
private function display():void
{
field.text = _text;
var g:Graphics = background.graphics;
g.clear();
g.lineStyle(0, 0x0);
g.beginFill(0xFFFFFF);
g.drawRoundRect(0, 0, field.width, field.height, CORNER_RADIUS);
}
}
}
其他提示
我结束了在Flash中创建一个圆角矩形和出口作为自己的阶级 - hotspotBG
var hotspotBackground:hotspotBG = new hotspotBG();
hotspotBackground.width = textField.width + 10;
caption.addChild(hotspotBackground);
您不能更改文本字段它的自我,截至2014年闪存不允许。
你可以做的是删除背景和边框, 这将离开文本字段完全透明的, 然后添加一个图像(矩形工具就是做最简单的方法)的文本字段的后面, 使得文本字段是在图像的顶部(z轴明智)
这可能不是你想到它的工作方式,但地狱!
//you are deleting the background and the borders
//and replacing them with an image
textbox.background=false;
textbox.border=false;
您可以只使用CSS样式?是这样的:
TextInput {
borderStyle: solid;
borderThickness: 1;
cornerRadius: 2;
}
我没有测试过这一点,但应该给你一个圆角。
不隶属于 StackOverflow