Skip to main content
Known Participant
June 21, 2011
Question

Can't make text the right size

  • June 21, 2011
  • 1 reply
  • 388 views

HI , I'm having a frustrating problem. I'm trying to get the text announcing the levels in my game to be the right size when it's online. It works fine offline, but when I put the swf up online the text looks like it's about 2.4 instead of 24 like I am trying to get it. Here's the code in the start game method:

public function startGame():void

{

canFire = true;

paperHeadlineIsAdded = false;

NumOfDrops = 0;

pastLevelTwenty = false;

gameIsOver = false;

speedVar = 90;

textRemoved = true;

origNumOfPlanes = 25;

waitForNewLife = false;

newLevel = false;

bombDropSpeed = 3;

NumOfPlanes = origNumOfPlanes;

airplanes = [];

bullets = [];

bombs = [];

// init score

lives = 3;

shotsLeft = 10;

shotsHit = 0;

showGameScore();

levelNum = 1;

iconArray = [];

// create gun

aagun = new AAGun();

aagun.gotoAndStop(57);

addChild(aagun);

// create object arrays

airplanes = new Array();

bullets = new Array();

bombs = new Array();

//text formatting

textFormat = new TextFormat();

textFormat.font=font.fontName;

textFormat.font = "Guadalupe";

textFormat.size = 24;

textFormat.align = "center";

textFormat.color = 0xffffff;

trace(getChildAt(numChildren-1).name);

livesIcons();

// listen for keyboard

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);

stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);

//setup your fireTimer and attach a listener to it.

fireTimer = new Timer(300, 1);

fireTimer.addEventListener(TimerEvent.TIMER, fireTimerHandler, false, 0, true);

// look for collisions

addEventListener(Event.ENTER_FRAME,onEnterFrame);

var siren:Sound = new Siren();

chanD = siren.play(0,800);

// start planes flying

setNextPlane();

}

and here's the rest of the code that puts the text up in this method:

public function wait():void {

if(levelNum>19){

thisIsTheEnd();

pastLevelTwenty = true;

gameIsOver = true;

newLevel = false;

}

if(newLevel == true){

if(aagun.aagunGone == false){

textFormat = new TextFormat();

textFormat.font=font.fontName;

textFormat.font = "Guadalupe";

textFormat.size = 24;

textFormat.align = "center";

textFormat.color = 0xffffff;

levelNum ++;

speedVar+= 25;

newLevelText = new TextField();

newLevelText.width = 550;

newLevelText.y = 110;

newLevelText.selectable = false;

newLevelText.defaultTextFormat = textFormat;

newLevelText.embedFonts=true

newLevelText.defaultTextFormat.size = 24;

newLevelText.text = "Level "+ String(levelNum);

waitForNewLife = true;

addChild(newLevelText);

textRemoved = false;

}

}

if (gameIsOver != true){

waitTimer = new Timer(5000,1);

waitTimer.addEventListener(TimerEvent.TIMER_COMPLETE, startNewLife);

waitTimer.start();

}

}

anyone have an idea why this is happening? Please let me know. Thank you.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 21, 2011

publish an html file, as well as a swf, upload them both and open the html in your browser.

Known Participant
June 21, 2011

I can't upload the html file with the swf because the place I have my game uploaded only asks for an swf file. Do you know why it doesn't work? when I load the html in my browser it works but not just the swf online.