04-30-2012, 04:17 PM
|
#1
|
|
Registered User
Join Date: Mar 2012
Posts: 39
|
Fonts and embedding help
Can anyone explain embedding fonts please ? Here is a file that works while I am writing it, but when I save it, it doesn't work anymore.
I have tried to Embed fonts, but when I click on UpperCase, LowerCase etc, nothing happens - I have even tried to click ALL. Upper, Lower are already in the list, so maybe they are already embedded - but this doesn't seem to work. I am guessing that the problem is that, but I could be wrong.
Again, this works perfect while I write it and test it - the text displays in black. I save it, close the file and open it again, the text does not show up.
Thanks in advance.
|
|
|
04-30-2012, 08:42 PM
|
#3
|
|
Registered User
Join Date: Mar 2012
Posts: 39
|
Thank you for the tip, I didn't realize it takes all that code just to get the font to show up.
Is my problem the font embedding then? Did you test my file?
|
|
|
04-30-2012, 09:41 PM
|
#4
|
|
Registered User
Join Date: Mar 2012
Posts: 39
|
Lord knows I am trying, but this is making me see spots.
My text is reverting to some other color or disappearing when I try to place it on stage. As I have said, I am working from two different computers, one here and at school.
I run the program like this below and it works until I save it. Once i save it and reopen it, it stops displaying the text. BUT when I start writing the code with a static text box with a black font before I start programming, it seems to display fine. I am just going nuts here?
And yes, I must be - because I shut down flash and restarted and all of a sudden, my location_txt is no longer there. This is very frustrating.
I have included pics to help out.
ActionScript Code:
var myFormat:TextFormat= new TextFormat();
var myFormat2:TextFormat= new TextFormat();
myFormat.color=0x000000;
myFormat.size=15;
myFormat2.color=0X0088ee;
myFormat2.size=20;
addChild(body_txt);
body_txt.text="What ?";
body_txt.setTextFormat(myFormat2);
addChild(location_txt);
location_txt.text="You are here";
location_txt.setTextFormat(myFormat);
Last edited by netrate; 04-30-2012 at 10:56 PM.
|
|
|
05-01-2012, 05:01 AM
|
#5
|
|
Site Contributor
Join Date: Jun 2006
Posts: 3,160
|
If you place a textbox on the screen in the authoring tool (Flash), you don't also have to use addChild() on it with code. So the line:
addChild(location_txt);
...is redundant and doesn't do anything at all. You have already added it to the display manually in Flash. Two different ways of doing the same thing.
Similarly, if you format your text in the properties panel, there is no need to also do it with code using a TextFormat object. They are just two different ways of doing the same thing, one in the properties panel, and the other dynamically when your program runs. Sometimes there *might* be a reason to do both, but probably not in your case right now.
You are not the first person to take on font embedding to try and discover how it works. Keep going and you will definitely figure it out. One thing to realize is that the font ultimately comes from your computer system. Another is to realize what are the roles of your fla file and your swf file here. You tell your fla file to embed the font. This is like saying "when you make me a swf file from this (CTRL-ENTER to test movie always makes a new swf), I want you to go to my system, get such-and-such a font, and embed it in my swf file." In other words, the font is never embedded in the fla file, the fla file effectively just contains the command to "go and get it." The font is embedded in the swf file, not the fla file.
This means that if I author a fla file, asking it to embed a certain font, then I send you that file, and you compile it (CTRL-ENTER), the font will only be embedded for you if the exact same font is present on your system.
However, if I send you the swf file, which is already compiled, and you run it, you will see the font displayed even if it is not present on your system.
|
|
|
05-01-2012, 05:34 PM
|
#6
|
|
Registered User
Join Date: Mar 2012
Posts: 39
|
Thank you for the reply.
I guess I am trying and trying, but still really confused and frustrated.
I am using only the Arial font - something that is technically on every system, yet, I am getting the same happening - works when i write it, save it and then doesn't display any text when I close flash and open it again.
I have broken the code down to its simplest form (without the addChild - thanks for the tip), and yet I am getting the same issue. I guess the real problem is that I must be missing some fundamental. For me, it is like saying "trace(0)" and seeing it work, only to find it not working the next time I start the program.
ActionScript Code:
var myFormat:TextFormat= new TextFormat();
var myFormat2:TextFormat= new TextFormat();
myFormat.color=0x000000;
myFormat.size=15;
myFormat2.color=0X0088ee;
myFormat2.size=20;
body_txt.text="What ?";
body_txt.setTextFormat(myFormat2);
location_txt.text="You are here";
location_txt.setTextFormat(myFormat);
|
|
|
05-01-2012, 05:43 PM
|
#7
|
|
Registered User
Join Date: Nov 2009
Location: Sri Lanka
Posts: 45
|
1.Select the text field.
2.Go to properties > Character > Anti-alias
3.Select "Use device font" option
|
|
|
05-01-2012, 05:51 PM
|
#8
|
|
Registered User
Join Date: Mar 2012
Posts: 39
|
Thanks for the tip, but I just tried that "Device Font Option", as you suggested and it did NOT work. Very frustrating...
Again, the file and script. I keep telling myself, I am not stupid, I am not stupid...
ActionScript Code:
var myFormat:TextFormat= new TextFormat();
myFormat.color=0x000000;
myFormat.size=15;
location_txt.text="Here you are";
location_txt.setTextFormat(myFormat);
|
|
|
05-01-2012, 06:26 PM
|
#9
|
|
TweenMax Salesman
Join Date: Jan 2012
Posts: 488
|
To use an embedded font, you need to do this:
1. In the font embedding options, go to the font you want to embed, go to the Actionscript tab, set Outline format to Classic(DF3) if using Classic textfield, or TLF(DF4) if using TLF. Check the "export for actionscript" checkbox and give the font a class name (we'll use class name MyFont)
2. Then to apply this font to a textfield, use the code below:
ActionScript Code:
var font:MyFont = new MyFont();
var myFormat = new TextFormat( font.fontName, 16, 0x666666 ); //If using the bold version of a font, TextFormat.bold must be set to true
location_txt.text="Here you are";
location_txt.setTextFormat(myFormat);
location_txt.embedFonts = true;
|
|
|
05-02-2012, 02:11 AM
|
#10
|
|
Site Contributor
Join Date: Jun 2006
Posts: 3,160
|
I repeat "if you format your text in the properties panel, there is no need to also do it with code using a TextFormat object."
What part of that did you not get?
Click the embed button in the properties panel and check off uppercase, lowercase, numerals and punctuation. Done. All this stuff you are doing with code is unnecessary. The only code you need in your case is the code that sets the text property:
location_txt.text = "You are here";
Edit: "Use device font" is bad advice. This makes the swf look for the font on the end user's machine, and it will replace it with something different if it is not found.
Last edited by Mazoonist; 05-02-2012 at 02:14 AM.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:26 AM.
///
|
|