Creating Flex Component View using Flash CS5

September 27, 2012

We created some Flex based component views using Flash CS5 by following the instructions in the Adobe Article Combining animation and ActionScript using Flash Professional CS5 and Flash Builder 4 which we used inside our course player. These View components had text fields which would dynamically resize when the player was resized on the fly(Only for firefox and safari, IE and chrome do not allow resizing). These views also had images which would scale appropriately as well.

Note this led to my series on embedding fonts due to conflict messages with respect to flex based textfield and flash based textfields(This is explained in detail in Part 3 of the series).

Advertisements

Flash CS5 Dynamic Text Formatting – Part 5

May 4, 2011

Embedding Font Class in a Flash CS5 Component Class

I created a document class for a fla file which has

  • font embedded
  • traces the font info when the class is instantiated
  • creates a text field to display embedded font

Here is the document class EmbedFontTest.as which is in the same directory as the Font Classes which it references(ArialEmbedder and MsRefEmbedder):
Continue reading


Flash CS5 Dynamic Text Formatting – Part 4

May 4, 2011

Embedding font in a Class file

My next approach was to read up on embedding fonts programmatically. So I broke out my Essential Actionscript 3.0 book and on page 740 read up on embedding fonts and going through the exercises in that chapter.

The following is an example of embedding font in a class which can then be used in a class to control the rendering of text in a TextField.

package {
	
	//-------------------------------------------------------------------------
	// Class
	//-------------------------------------------------------------------------
	/**
	 *
	 * Class used to embed Arial Regular font 
     * ONLY in a font library
	 * for use by Flash 5 Pro generated swc libraries
	 *
	 **/ 
	public class ArialEmbedder {
		
		public static const FONT_NAME:String = "_arial";
		
		//these are the elements of the font family 
		//we want to embed using direct path location 
        //to Font directory on Windows XP
		[Embed(source='C:/Windows/Fonts/ARIAL.TTF', 
			   fontFamily='_arial',
			   fontWeight='regular',
			   fontStyle='regular',
			   embedAsCFF='false')]
		public static var _arial:Class;
		
	}
}

Continue reading


Flash CS5 Dynamic Text Formatting – Part 3

May 4, 2011

Creating Flex Component View using Flash CS5 – FONT Conflicts

We created some Flex based component views using Flash CS5 by following the instructions in the Adobe Article Combining animation and ActionScript using Flash Professional CS5 and Flash Builder 4 which we used inside our course player. These View components had text fields which would dynamically resize when the player was resized on the fly(Only for firefox and safari, IE and chrome do not allow resizing). These views also had images which would scale appropriately as well.

Continue reading


Flash CS5 Dynamic Text Formatting – Part 2

May 4, 2011

Mixing TextFormats within a TextField
We would like to highlight text within a paragraph. I would follow the instructions in Part 1 of this series, then follow these instructions to modify the text format within a paragraph:

  • create a new TextField with the desired font to be used
  • embed the font in the TextField
  • Set the font to be exported for actionscript*

* see the instructions at this site: AS3: Text Fields and Formats to set the linkage properties for the font in the IDE.

Continue reading


Flash CS5 Dynamic Text Formatting – Part 1

May 4, 2011

Retrieving TextFormat from TextField with Embedded Font
Creating notes for myself to reference when creating flash pages using the Flash CS5 IDE.

This post is going to cover how to retrieve TextFormat settings when I would like to change the text in dynamic text fields on the fly. I typically layout flash pages with TextFields placed in the desired location on the stage. When an interaction has been setup and the values of the text fields needs to change dynamically, I always struggle to remember exactly what I did each time.

Simple approach Part 1:

  • Embed the font in the dynamic TextField with desired attributes set in property tab
  • TextField paragraph setting set to Justify*
  • Programmatically retrieve the TextFields text format properties to be used later

* – this seems to prevent cropping of characters in the text field when values are changed. When I tried to set this attribute programmatically, the text characters would get cropped when I mixed font attributes within a text field vs setting the whole TextField from the stage (so just set this item globally on the stage properties tab view for the designated TextField).

Continue reading