View Full Version : [FMX] problem displaying fonts w/.embedFonts & .createTextField
Mr. X
November 13th, 2002, 07:41 PM
I'm stuck on this one for the 2nd day and it's driving me crazy! So I joined these forums in the hope to be enlightened by some Flash guru :)
OK, so I'm making a site with 4 main buttons. Each of them send you to the sub-section and I'm making the sub-category buttons from 4 arrays with the names of each subCat and a .duplicatMovieClip loop.
My problem is that I can't get the font I'm using (Adobe "Myriad Web Bold") to display those subCat...
I tried using a "dummy" dynamic text field off stage with embedded font as well as adding/linking the font into the library.
When I do a "Size Report" the font seem to be embedded but the text doesn't show up. When I set ".embedFonts = true;" to "false" then the text comes back (but in device font of course...)
I've tried everything I could think of but I'm stuck...
I'd be glad to send the .fla to anyone with time to help... :)
Here some of the code:
// creates the new buttons
for (i=0; i < subCat_array.length; i++) {
_root.subCat_masterBT_mc.duplicateMovieClip(subCat _array[i]+"_mc", 100+i);
_root[subCat_array[i]+"_mc"]._x = _root.subCat_masterBT_mc._x;
_root[subCat_array[i]+"_mc"]._y = _root.subCat_masterBT_mc._y-(_root[subCat_array[i]+"_mc"]._height*(i+1));
// add text to each button
_root[subCat_array[i]+"_mc"].createTextField(subCat_array[i]+"TXT_mc", 150+i, 0, 0, 150, 20);
_root[subCat_array[i]+"_mc"][subCat_array[i]+"TXT_mc"].text = subCat_array[i];
_root[subCat_array[i]+"_mc"][subCat_array[i]+"TXT_mc"].embedFonts = true;
_root[subCat_array[i]+"_mc"][subCat_array[i]+"TXT_mc"].multiline = false;
_root[subCat_array[i]+"_mc"][subCat_array[i]+"TXT_mc"].setTextFormat(_root.subCat_TXT);
}
};
// text formatting for the subcategory's submenus
subCat_TXT = new TextFormat();
subCat_TXT.color = 0xFFFFFF;
subCat_TXT.size = 14;
subCat_TXT.align = "right";
subCat_TXT.font = "Myriad Web Bold";
sbeener
November 13th, 2002, 08:17 PM
i notice that your setting the text format of the buttons to subCat_TXT before defining subCat_TXT.
is that the same order as in your fla?
setting the font of the TextFormat object can be a little tricky. if it's not exactly right (including bold, italic, underline) it won't work. it's not case sensitive however, you can use caps indiscriminately.
what will work across the board, is using the name you export it as in the linkage option from the library (which can be anything). this is not the same as the name of the font object as it is displayed in the library, but the name which appears in the linkage options.
Mr. X
November 14th, 2002, 02:36 AM
"i notice that your setting the text format of the buttons to subCat_TXT before defining subCat_TXT. is that the same order as in your fla?"
yes, it's in the same order. But I don't think it matters since the code you see is actually part of a function I created: subCat_BTcreate = function (subCat_array) {...
Those subCat buttons are created only when the function is called from a on (Release) on the main Category's buttons. Plus, all the other attributes of subCat_TXT (color, size, etc...) work fine...
"what will work across the board, is using the name you export it as in the linkage option from the library (which can be anything). this is not the same as the name of the font object as it is displayed in the library, but the name which appears in the linkage options."
I tried setting the linkage identifier as "myFont" and then putting:
subCat_TXT.font = "MyFont";
but that did not work either... That's what you mean right?
Anyway, thanks for the help and sorry about the cross post in Flash MX section, I arrived their through a search and realized there was an AS section only after posting in MX... SORRY! :)
lostinbeta
November 14th, 2002, 02:41 AM
No need to be sorry Mr. X, just we get A LOT of people here that post their question in every section thinking it will help them get an answer faster.
Your question was actually applicable in either this or the MX section.
As for the problem, I don't think I have experienced that problem before, so I don't know of a solution. Did you try doing this with a different font at all?
sbeener
November 14th, 2002, 03:19 AM
I tried setting the linkage identifier as "myFont" and then putting:
subCat_TXT.font = "MyFont";
yeah, that's what i meant...
hmmm.
lib's suggestion of trying with a different font is a good one.
try something like this in an empty fla:
_root.createTextField("txt",0,0,0,0,0);
_root.txt.autoSize = "left";
_root.txt.text = "hi, i'm arial";
_root.txt.setTextFormat(new TextFormat("myFont",18));
you need to create a font called "myFont".
i found i didn't even have to export it. bizarre.
lostinbeta
November 14th, 2002, 03:29 AM
Hey sbeener, I notice that lets you choose any font on your computer, which is pretty cool, but how does that help it on the web?
It would be so much easier if this was like CSS and you could upload the .ttf font to your server and link to it so everyone can see it. I am supposing that isn't possible right?
Mr. X
November 14th, 2002, 03:59 AM
Thx sbeener,
ok, I'm starting to wonder if there's something that I'm really missing in the font embedding busines... Maybe something so obvious that you didn't think about mentionning? All I know about embedding fonts is what I read in the online Help and it's pretty sparse...
So, I just copied/pasted the code you gave me in a brand new .fla and I added a font called "font 1" in the Library. Then I went to Linkage, selected "export for ActionScript" and gave it an identifier name: "myFont".
Then I selected my problematic font in the Property window (the one you get w/ right click on the font in lib) and it did not work.
Then I selected Arial, Helvetica, and Courier (in the "lib/right click" property) and each time I get the same default browser font (Times or something like that...)! Did not work, even with Courier...
I'm on OS X 10.2.2, Flash MX, I tried the published .fla in IE 5.2, and Chimera (Mozilla based OS X browser)...
Any thoughts?...
Mr. X
November 14th, 2002, 04:25 AM
on the size report of the test .fla w/ the code you gave me, I get this
Movie Report
-------------
FrameFrame # Frame Bytes Total Bytes Page
------------ ----------- ----------- ---------------
1 21212 21212 Scene 1
Page Shape Bytes Text Bytes
----------------------- ----------- ----------
Scene 1 0 89
Sound name Bytes Format
----------------------- --------- ----------
Arial 20800 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéè êëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨!=ÆØ?±<=>=¥µ?<sum>?<pi>?ªº?æø¿¡¬?ƒ??«»…_ÀÃÕŒœ–—“”‘’÷?ÿŸ/€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔ?ÒÚÛÙ?ˆ˜¯<breve>??¸´´?<caron>
is it supposed to say "Sound Name" down there? I'd expect it to be called "font name"... Could you check what it says on your system? thx.
sbeener
November 14th, 2002, 12:05 PM
lib - flash embeds the font information in the swf. i agree, linking to a ttf would probably be simpler. one upside to the way it works now is that you don't need to embed all the characters.
X - strangeness... my bandwidth report calls it a sound too so i think you're ok there.
i can't see what's missing for you. my initial impulse is to blame osX. ; )
here's a fla and swf containing code that works for me. you may have to re-embed the font, i'm on a pc.
Mr. X
November 14th, 2002, 12:39 PM
ok, your file looks pretty much identical to mine. I don't really understand what you mean by "you may have to re-embed the font"
The .swf should show up as Arial no matter on what OS right? That's the purpose of embedding in the 1st place... Anyway... It doesn't... :(
Then I just went ahead and tried selecting my own Arial font and re-publishing the .fla, just in case... Did not work...
I don't feel really comfortable posting the .fla here since it's going to be someone's site. But I'd be glad to e-mail it to you if you have time to check if it works on your system.
This thing is starting to look like a bug to me... ;)
thx again for your help! :)
sbeener
November 14th, 2002, 10:49 PM
umm, oops.
i forgot to add:
_root.txt.embedFonts = 1;
let me know if that clears up the problems in the test file.
i pm'ed you my email. it's been bouncing back for most of the afternoon ... grrr ... but should be working again soon.
Mr. X
November 15th, 2002, 04:39 AM
yeah, with this extra line, your .fla works. So, I can stop blaming OS X and get back to concentrating on my poor scripting hability... :)
Sorry for such a basic question but, where do I view the pm on this forums? (don't use forums much, it's 4:37 am and I just don't feel like looking through FAQs and stuff right now :)
or you can e-mail me at yb@mrxsss.com and I'll send you the file...
THX!
upuaut
November 15th, 2002, 04:48 AM
Personal Messages are a catagory at the bottem of the main Kirupaforum screen. Its the last forum below all the others.
(btw welcome to kirupaforum.com. and don't worry about easy questions. I'm a seasoned 5.0'er and I couldn't even begin to contemplate what you were asking in this thread. :) )
Mr. X
November 15th, 2002, 02:41 PM
thanks David. I'll definitly stick around even after I solve my problem. Everyone is pretty nice around here. No attitude... It's refreshing to see that on the net :)
Sbeener, I e-mailed you the file. And I'll take a look at it again now that I know it's my scripting that sucks... But gotta go to work now :(
sbeener
November 15th, 2002, 05:41 PM
X, your scripting looks just fine to me!
i still have no idea why the fonts were not working. however, changing the duplicateMovieClip to attachMovie solved it for me. this has the added advantage of allowing you to remove the unused 'seed' clip from the stage
weird that it made a difference...
i've emailed you back the fla i amended. i changed a few other things too ...
i made some of your functions MovieClip methods and encapsulated the text addition in it's own method.
i used temporary variables to refer to newly created clips in some of the methods.
i changed the method of clearing the old menu.
of course you should feel free to change anything back or whatever.
cheers.
Mr. X
November 22nd, 2002, 03:28 AM
never got a chance to thank you. Work got crazy and this project has been on stad by for a few days... I looked at what you did and I don't know anything about prototype... I looked at the help in Flash but (as most of the time) it's written by people that don't understand that some of us are more comfortable with watercolors than calculators... Any tip on where I can find understandable info about prototype?
Thanks again for the help! :)
lostinbeta
November 22nd, 2002, 03:30 AM
You can check the AS Tricks section on this site.
http://www.kirupa.com/developer/actionscript/as_tricks.asp
Click on the link that says...."using prototypes instead of functions"
That is where I learned how to use prototypes.
Mr. X
November 22nd, 2002, 03:39 AM
thx lib. Do you ever sleep? ;)
lostinbeta
November 22nd, 2002, 03:40 AM
Nope, thats the beauty of having a sleeping disorder :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.