PDA

View Full Version : Displaying Text



vivaretro
May 12th, 2008, 12:00 PM
Hi, I swear I've gotten this to work when I just did it on the main timeline
but as part of a package I can't seem to get my text to appear...


package
{

import flash.text.*;
import flash.display.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;

public class fontMaker extends MovieClip
{
var beloDin:Font = new Belo();

var myFormat:TextFormat = new TextFormat();
var countyTextFieldBelo:TextField = new TextField();
var countyFormat:TextFormat = new TextFormat();
var test:String = "test";

public function fontMaker()
{

trace("fontmaker is run");

countyFormat.font = beloDin.fontName;
countyFormat.size = 600;
countyFormat.color = 0x000000;
countyTextFieldBelo.autoSize = TextFieldAutoSize.LEFT;
countyTextFieldBelo.defaultTextFormat = countyFormat;
countyTextFieldBelo.embedFonts = true;
countyTextFieldBelo.alpha = 1;
countyTextFieldBelo.text = test;
countyTextFieldBelo.x = 300;
countyTextFieldBelo.y = 400;
countyTextFieldBelo.selectable = false;
countyTextFieldBelo.width = 1920;
countyTextFieldBelo.height = 1080;

keyFont();

}

public function keyFont()
{

trace ("keyFont has run");

addChild(countyTextFieldBelo);

}
}
}

ahmednuaman
May 12th, 2008, 12:17 PM
try stage.addChild(countyTextFieldBelo);

vivaretro
May 12th, 2008, 12:27 PM
try stage.addChild(countyTextFieldBelo);

I added that and now get this error:

1120: Access of undefined property countyTextFieldBelo.

ahmednuaman
May 12th, 2008, 12:31 PM
try: public var countyTextFieldBelo:TextField = new TextField();

vivaretro
May 12th, 2008, 12:34 PM
try: public var countyTextFieldBelo:TextField = new TextField();



I still get the same error.

ahmednuaman
May 12th, 2008, 12:40 PM
Instead of: countyTextFieldBelo.defaultTextFormat = countyFormat;
Try: countyTextFieldBelo.setTextFormat(countyFormat);

Read up on this: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html

(Because the error is: 1120: Access of undefined property countyTextFieldBelo. It's saying that it can't find one of the specified properties as being part of the TextField format)

vivaretro
May 12th, 2008, 12:48 PM
Instead of: countyTextFieldBelo.defaultTextFormat = countyFormat;
Try: countyTextFieldBelo.setTextFormat(countyFormat);

Read up on this: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html

(Because the error is: 1120: Access of undefined property countyTextFieldBelo. It's saying that it can't find one of the specified properties as being part of the TextField format)

Thanks!

ahmednuaman
May 12th, 2008, 12:59 PM
So it work yea?

vivaretro
May 12th, 2008, 01:41 PM
So it work yea?

not yet. I changed
public class fontMaker extends MovieClip
to
public class fontmaker extends Sprite
then put
var Floader:Sprite = new fontMaker;
in my main Document class
that got rid of the error but still no font visible on the stage.

ahmednuaman
May 12th, 2008, 03:04 PM
Oh ok, yes, inheritance, it's a *****. Basically, I had the same sort of problem as you. So within your document class, you're calling it new fontMaker yeah?

Change keyFont() to return TextField and then in your document class do:

var fontMaker = new FontMaker();
stage.addChild(fontMaker.keyFont());

And that should work.

vivaretro
May 12th, 2008, 03:26 PM
I noticed fontMaker was changed to FontMaker at:

var fontMaker = new FontMaker();

is that right?

I get this error:
1180: Call to a possibly undefined method FontMaker.

if I make it var fontMaker = new fontmaker();
I get this error:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Document()

plus how do I change keyFont to return TextField?