I'm doing a game and would like to increase the size of the score since it's too small
Thanks for the answer
This is the code for the score:
var score_txt:TextField=new TextField();
score_txt.textColor=0xFFFFFF;
score_txt.x=142,3;
score_txt.y=563,05;
note:the score must be TextField not TextFormat
have you tried this?
score_txt.width = 100;
score_txt.height = 100;
Using a TextFormat could be easier:
var myFormat:TextFormat = new TextFormat();
myFormat.size = 15;
score_txt.defaultTextFormat = myFormat;
score_txt.text = "your text"
Related
I trying to mask a textField with the following code, but it's not working.
var Blue_clip:blue_img = new blue_img()
addChild(Blue_clip)
var field:TextField=new TextField();
var format:TextFormat=new TextFormat();
format.size = 40;
format.font = "Arial";
field.defaultTextFormat = format;
field.text = "Hello World";
addChild(field);
Blue_clip.mask = field;
Please guide me.
Method 1) - Use runtime AS mask
_root.attachMovie("mask", "mask_instance", 3 ,{_x:10, _y:20});
_root.masked_content_mc.setMask(mask_instance);
where mask is AS exported movie clip in lybrary (simple shape 100x100px for example)
Method 2) - Embed font.
You have to embed the font using Text->Font Embedding and then set it to the text field:
var style_tf:TextFormat = new TextFormat();
style_tf.font = "ArialEmbed";
style_tf.size = 16;
_root.my_text.setTextFormat(style_tf);
I have a bitmap data which draw a text field. after scaling, text are distortion.
I using following code:
// tf is text Field and bm is bitmap.
var tf:TextField = new TextField();
tf.text = "Hello world";
var bd:BitmapData = new BitmapData(200, 200, true, 0x00ff00);
bd.draw(tf);
var bm:Bitmap = new Bitmap(bd);
addChild(bm);
bm.scaleX = 2;
bm.scaleY = 2;
Please guide me.
You should use transform matrix to draw an upscaled text field (or any other vector graphics object) onto a BitmapData.
var mat:Matrix=new Matrix();
mat.scale(2.0,2.0);
bd.draw(tf,mat);
First, increase the font size and then convert and scale as bitmap like so,
//---- Text format ----
var textFormat:TextFormat = new TextFormat();
textFormat.font = "Arial";
//textFormat.bold = true;
textFormat.size = 40;
//---------------------------------------------
//
var tf:TextField = new TextField();
tf.text = "Hello world";
/*tf.antiAliasType = AntiAliasType.ADVANCED;
tf.gridFitType = GridFitType.PIXEL;
tf.thickness = 0;
tf.sharpness = 0;*/
tf.setTextFormat(textFormat);
//
//
var bd:BitmapData = new BitmapData(200,200,true,0x00ff00);
bd.draw(tf);
var bm:Bitmap = new Bitmap(bd);
bm.smoothing = true;
addChild(bm);
bm.scaleX = 2;
bm.scaleY = 2;
Best luck.
I am trying to create a text field manually from actionscript alone. I got parts of it but now i don't know how to give the fonts size and different fonts can somebody tell me how to go about this?
for (var i:Number = 0; i < weekdaystringArray.length ; i++)
{
weekdaystring.text = weekdaystringArray [i];
weekdaystring.x = 150;
weekdaystring.y = 994;
addChild (weekdaystring);
weekdaystring.textColor = 0xFFFFFF;
}
This is what I have so far...
You need to apply a TextFormat to the TextField with the setTextFormat() method.
var format:TextFormat = new TextFormat();
format.font = "Courier";
format.size = 24;
// then inside your loop:
weekdaystring.setTextFormat(format);
it need to apply a TextFormat to the TextFiled
var format:TextFormat = weekdaystring.defaultTextFormat;
format.font = "courier";
format.size = 24
weekdaystring.defaultTextFormat = format;
I've a problem to change the font-color of a TextField after it has been added as a child to a MovieClip.
My code:
var btn:MovieClip = new MovieClip();
// other code for button
var tf:TextFormat = new TextFormat();
tf.size = 12;
tf.bold = true;
tf.font = "Arial"
tf.color = 0x000000;
var capt:TextField = new TextField();
capt.defaultTextFormat = tf;
capt.width = 200;
capt.height = 50;
capt.text = "Test";
capt.y = 20;
capt.x = 20;
capt.border = false;
capt.selectable = false;
btn.addChild(capt);
// .....
How can I Change the font-color after the last line?
It sounds like you're looking for TextField.setTextFormat(). You can either adjust your original TextFormat or just make a whole new one.
tf.color = 0xFF0000;
capt.setTextFormat(tf);
Assuming the TextField falls out of scope after that last line (you don't show enough to know if it does or not), you'll need to loop through the button to get the TextField and do it from there.
var i:uint;
var l:uint = btn.numChildren; //numChildren and length are 'heavy' getters, never use them as restrictors in a loop
for ( i = 0; i < l; i++ ) {
var cur:DisplayObject = btn.getChildAt( i );
if ( cur is TextField ) {
( cur as TextField ).setTextFormat( /*set new TextFormat in here*/);
break;
}
}
That assumes there is only the single TextField, of course. If there are multiple, I would extend MovieClip and add a public property for the value you want to change.
You can also just use the textColor property of a textfield:
capt.textColor = 0xFF0000;
How can I set the properties for the text outline / border for each character in a line of text in AS3 ?
I don't think you can. What you can do is use a blur filter to mimic the appearance of an outline. Just paste this into an empty AS3 movie:
var txt:TextField = new TextField();
this.addChild(txt);
txt.appendText('Lorem ipsum');
txt.autoSize = TextFieldAutoSize.LEFT;
txt.antiAliasType = flash.text.AntiAliasType.NORMAL;
txt.selectable = false;
var txtFormat:TextFormat = new TextFormat();
txtFormat.size = 40;
txtFormat.font = 'Helvetica';
txt.setTextFormat(txtFormat);
txt.defaultTextFormat = txtFormat;
var outline:GlowFilter = new GlowFilter();
outline.blurX = outline.blurY = 1;
outline.color = 0xFF0000;
outline.quality = BitmapFilterQuality.HIGH;
outline.strength = 100;
var filterArray:Array = new Array();
filterArray.push(outline);
txt.filters = filterArray;
Try playing with the strength, blurX, blurY and quality properties, in order to obtain different appearances. I think that's about the closest you can get to a text outline.
PS: font embedding would greatly improve the quality of the effect, as well as making the antialias work properly.
i am not shore i understand but you can use same kind of
filter on the testbox and by doing so you can get a same kind of a border
in each one of your letters