It's a dynamic text field, it updates my score.
It works, as in it does update the score, and the border shows the color I want it to, and it's located where I want it, but I can't seem to change the color and font and font size of the actual text inside the text field.
Here is the part of my code that is relevant.
ActionScript Code: package { import flash.media.Sound; import flash.display.Bitmap; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.ui.Mouse; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType;
ActionScript Code: public class Game extends Sprite { private var _mos:Bitmap = new Assets.mos(); private var _swatter:Bitmap = new Assets.swat(); private var _blood:Bitmap = new Assets.blood(); private var _background:Bitmap = new Assets.background(); private var _squish:Sound = new Assets.squish(); private var _blueBird:Bitmap = new Assets.bluebird(); private var _redBird:Bitmap = new Assets.redbird(); private var _greenBird:Bitmap = new Assets.greenbird(); private var _yellowBird:Bitmap = new Assets.yellowbird(); private var _points:Number = 1; private var _scoreText:TextField = new TextField(); private var _format:TextFormat = new TextFormat(); private var _chirp:Sound = new Assets.chirp();
ActionScript Code: public function Game():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); displayObjects(); }
ActionScript Code: private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); stage.addEventListener(MouseEvent.MOUSE_MOVE, followSwatter); stage.addEventListener(MouseEvent.CLICK, moveMos); stage.addEventListener(MouseEvent.CLICK, addPoints); stage.addEventListener(MouseEvent.CLICK, birdHit); stage.addEventListener(Event.ENTER_FRAME, updateScore);
ActionScript Code: public function displayObjects():void { _scoreText.type = TextFieldType.DYNAMIC; _scoreText.x = 387; _scoreText.y = 417; _scoreText.border = true; _scoreText.borderColor = 0xFF33FF; _scoreText.width = 60; _scoreText.height = 30; _format.font = "Verdana"; _format.color = 0xFF0000; _format.size = 20; _format.bold = true; _scoreText.setTextFormat(_format); addChild(_scoreText); } public function updateScore(evt:Event):void { _scoreText.text = String(_points); } public function addPoints(evt:MouseEvent):void { if (_swatter.hitTestObject(_mos)) { _points += 1; } }
I have searched and searched for a solution to this problem, nothing I've tried or thought of has worked.
Thanks in advance for whoever helps.
Can't change font size or color
Wednesday, June 6, 2012
[Action Script] Can't change font size or color June,2012
Posted by Bimo Hery Prabowo at 3:13 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment