FightSkillz.com - Life, Code, & Idiocy
KaTG book:What Do We Do Now? is in stores! pick it up at your local book store. doing so keeps the book available in stores. katg.com/book 13 hrs ago

Posts Tagged ‘Flex 3’

Embedding fonts in Flex 3

Friday, June 20th, 2008
Fonts are the creative content of the font designer or foundry, so if you don't have a collection of fonts you've paid for, and aren't planning on purchasing some, you should stick to free fonts. A good place to start is Google, you'll find plenty of foundries who make a few free fonts, and several sites like [http://www.fonts.com/]. You may choose to embed a particular font that came with your operating system for the sake of cross-platform uniformity as well, however you still need to make sure that it is either an OTF (Open Type Font) or TTF (True Type Font), as Flex works with these file types. There are ways to convert postscript and other font formats to OTF/TTF but it's tedious and you're better off finding a different compatible font You can also load fonts as an external resource in your apps similar to just calling a system font, however embedding them is the way to go. Embedded fonts can be anti-aliased, take part in effects, and are handled as a true asset and thus with a higher regard in your application. There are a number of ways to embed fonts in your Flex applications. If you're embedding a font that's active in your system you can specify the system name as in the following example:
@font-face {
src: local("Arial");
fontFamily: MyFont;
}
Likely however you'll not want to keep a whole bunch of fonts active or have to think about activating your project fonts every time you compile, in which case you can copy the font file to your project directory. In the example below the Arial font is in a 'fonts' sub-directory of my project:
@font-face {
src: url("/fonts/Arial.ttf");
fontFamily: MyFont;
}
Note: If you use spaces in the font family as in "My Font" you'll run into an issue where the font appears in Design View but isn't compiled with the app. There are other options that can be specified to customize your font-face:
fontStyle: normal | italic | oblique;
fontWeight: normal | bold | heavy;
advancedAntiAliasing: true | false;
These style declarations are placed within the mxml <mx:Style> tag. The above code uses CSS, which is best for styling and skinning your application, but if you prefer you can do the same thing in actionscript. For more information on how to, and why you should/shouldn't embed a font in your applications refer to [http://livedocs.adobe.com...fonts_09.html] Keep in mind that font files can be quite large, in the 5-12MB+ range and that size will be added to the weight of your application. It's best to use lighter fonts when creating online apps, in which case try to find one's under 200KB.

Downloading a File with Flex 3

Sunday, May 18th, 2008
I stumbled over this when I was building the CCMCP Library app but I suppose history's due to repeat itself. The problem is this: downloading a file from flex just doesn't work; A dialogue pops up, you choose a place to save the file, but when you hit save no file gets downloaded. If you're sure the url is correct and you haven't made any syntax errors, then the most likely cause is that you've declared the
'fileRef'
variable within the
'download();'
function. The following code will work.
private var fileRef:FileReference = new FileReference();
 
public function download():void
{
fileRef.download(new URLRequest('http://web-site/file-name'), 'simple filename');
}
The problem's also documented at Adobe and Lynch Consulting

Adobe Flex Builder 3

Sunday, May 18th, 2008
flexbuilder3Pretty much everyone that uses the internet knows about it, and according to Adobe 99%+ of browsers have it installed. Flash is a browser plugin that lets you view flash content, everything from games, to animation, video and more. Adobe Flex builder is an IDE(Integrated Development Environment) for flash. Where using Adobe Flash(software for making flash content) is foreign to most programmers because it's set up for animation and uses an approach based on frames, Flex Builder was designed for programmers. It lets you build RIAs(Rich Internet Applications) with the richness of flash, with the tools you need like code hinting/highlighting, debugging, and a set of usable, flexible controls. Flex uses Actionscript--the Flash programming language, along with MXML a simple xml schemed language used for the layout of your apps. Flex builder also has a design view that lets you visually arrange and edit the properties of the controls in your application. To use Flex 3 you can get Flex 3 Builder from Adobe or download the open source Flex 3 SDK(Software Development Kit) and use it with your IDE of choice. Flex Builder 3 and FlexBuilder 3 Pro have some extra features that the SDK doesn't, you can see the differences here.