Tuesday, January 24, 2006
 
So long Cambridge Uni!

For the last 14 months I have been on a rolling contract with Cambridge University. My girlfriend and I now wish to move to Bath, and so I've just handed in my resignation.

I'm going to take some time out before looking for work again (I plan to look in to Actionscript3 and Flex2 first). We've also considered working abroad, and so if anyone in Australia, Europe, Canada... is looking for an AS2 developer, feel free to get in touch! I would consider settling in to a permanent position if the location is right :)



 
Mixing HTML/CSS & Embedded Fonts

I get a lot of questions about font problems when using markup in Flash - as I was answering a forum thread this evening I thought it was about time I posted something to the blog - so here's a copy of my reply :)

There are a couple of things to be aware of when you're mixing HTML/CSS and embedded fonts.
Think of how normal HTML pages work - HTML doesn't embed fonts, it utilises what fonts the user has on his/her computer, which is why you need to specify a family of possible fonts in your CSS file - if the client's machine doesn't have one of them, it will use another one from the family instead.

Now think about what you may be trying to do in Flash. Flash does support HTML text, but if you embed a font in a Flash textbox you are telling it to use that font and that font only. If you then apply CSS which specifies a "font-family", you are giving Flash conflicting instructions - you are saying "Use this particular embedded font ..oh, and here's a choice of fonts to use as well". Poor old Flash gets confused. The result? It will usually display nothing at all. To get around this problem either do not specify a font-family in your CSS at all, or if you really want to specify a font-family, the *only* name in it must be the name of the embedded font.

For the same kind of reasons as mentioned above, normal HTML pages can easily display the normal, bold or italic version of a particular font together in one TextField. However, when you embed a font in Flash you usually choose to embed the normal version only - the bold and italicised versions are not embedded and so will not show up when you have HTML mark-up specifying bold or italicised text amongst normal text.

This is a bit of a problem because [to my knowledge] Flash is only designed to allow you to specify one embedded font per TextField. However, there is a workaround...

First, you embed the font you want to use, in the usual way. Next, create a couple of TextFields somewhere on the main timeline at author-time. In one, manually embed the bold version of that desired font (ie embed the font and then click the "B" button on the properties bar). In another, embed the italic version. Now you can have HTML mark up which displays normal, bold and italic text all in one box (note: you do not need to associate the bold and italic text with any particular TextField).
I hope this helps :)




Friday, January 20, 2006
 
I was recently asked if it was possible to create (CSS) styles within the IDE, and use them with an embedded font. Yes you can. The Flash dictionary is not very helpful so here's a quick example that will work for a Flash 7 movie:

/*requires a font in the library set to export with the linkage "myFont"*/
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
myStyle.setStyle(".testStyle",{fontFamily:'myFont',
textAlign:'center',
color:'#992299'});
this.createTextField("bob", 500, 50, 50, 100, 100);
bob = this["bob"];
bob.autoSize = "left";
bob.styleSheet = myStyle;
bob.html = true;
bob.embedFonts = true;
bob.border = true;
bob.multiline = true;
bob.wordWrap = true;
bob.text = "<span class='testStyle'>asdasdasdsadas</span>";

Note: Don't call your style 'style' - it can cause unexpected problems down the line.




ARCHIVES

  AS Hero   blog feed

nwebb.co.uk - flash tutorials, php and more.